Skip to content

Commit 5b02216

Browse files
authored
module classes can sometimes extend scala.runtime.AbstractFuntionN in Scala 2 (#24147)
Ported from: https://github.com/scala/scala/blob/6ecf74bfb4e914391fda1df5288ebaad6e4699b8/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala#L122 This is supposed to follow [this part of the spec](https://scala-lang.org/files/archive/spec/2.13/05-classes-and-objects.html#case-classes) but the implementation is somehow different...
2 parents 7bf6b7d + e7c79dc commit 5b02216

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

library/src/scala/UninitializedFieldError.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ import scala.language.`2.13`
2323
final case class UninitializedFieldError(msg: String) extends RuntimeException(msg) {
2424
def this(obj: Any) = this("" + obj)
2525
}
26+
27+
object UninitializedFieldError extends scala.runtime.AbstractFunction1[String, UninitializedFieldError]:
28+
override def toString: String = "UninitializedFieldError"

library/src/scala/collection/StringOps.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,3 +1651,6 @@ final case class StringView(s: String) extends AbstractIndexedSeqView[Char] {
16511651
def apply(n: Int) = s.charAt(n)
16521652
override def toString: String = s"StringView($s)"
16531653
}
1654+
1655+
object StringView extends scala.runtime.AbstractFunction1[String, StringView]:
1656+
override def toString: String = "StringView"

library/src/scala/reflect/package.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ package object reflect {
7676

7777
/** An exception that indicates an error during Scala reflection */
7878
case class ScalaReflectionException(msg: String) extends Exception(msg)
79+
80+
object ScalaReflectionException extends scala.runtime.AbstractFunction1[String, ScalaReflectionException]:
81+
override def toString: String = "ScalaReflectionException"

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ object Build {
15261526
val wrappedArgs = if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator))
15271527
val fullArgs = main :: (defaultOutputDirectory ::: wrappedArgs).map("\""+ _ + "\"").map(_.replace("\\", "\\\\"))
15281528

1529-
(Compile / runMain).toTask(fullArgs.mkString(" ", " ", ""))
1529+
(`scala3-compiler-bootstrapped-new` / Compile / runMain).toTask(fullArgs.mkString(" ", " ", ""))
15301530
}.evaluated,
15311531
testCompilation := Def.inputTaskDyn {
15321532
val args = spaceDelimited("<arg>").parsed

project/MiMaFilters.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -551,17 +551,6 @@ object MiMaFilters {
551551
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.Tuple3Zipped.coll2$extension"),
552552
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.runtime.Tuple3Zipped.coll3$extension"),
553553

554-
// singleton case classes modules inherit AbstractFunction1??
555-
ProblemFilters.exclude[MissingTypesProblem]("scala.ScalaReflectionException$"),
556-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.ScalaReflectionException.compose"),
557-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.ScalaReflectionException.andThen"),
558-
ProblemFilters.exclude[MissingTypesProblem]("scala.UninitializedFieldError$"),
559-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.UninitializedFieldError.compose"),
560-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.UninitializedFieldError.andThen"),
561-
ProblemFilters.exclude[MissingTypesProblem]("scala.collection.StringView$"),
562-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.StringView.compose"),
563-
ProblemFilters.exclude[DirectMissingMethodProblem]("scala.collection.StringView.andThen"),
564-
565554
// TO INVESTIGATE: This constructor changed, but it is private... why complaining?
566555
ProblemFilters.exclude[IncompatibleMethTypeProblem]("scala.collection.immutable.LazyList.this"),
567556
// This one should be fine, public class inside private object

0 commit comments

Comments
 (0)