diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 302c8c07f98a..dfc0aa526004 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -497,17 +497,6 @@ class Definitions { def staticsMethodRef(name: PreName): TermRef = ScalaStaticsModule.requiredMethodRef(name) def staticsMethod(name: PreName): TermSymbol = ScalaStaticsModule.requiredMethod(name) - // Dotty deviation: we cannot use a @tu lazy val here because @tu lazy vals in dotty - // will return "null" when called recursively, see #1856. - def DottyPredefModule: Symbol = { - if (myDottyPredefModule == null) { - myDottyPredefModule = getModuleIfDefined("dotty.DottyPredef") - assert(myDottyPredefModule != null) - } - myDottyPredefModule - } - private var myDottyPredefModule: Symbol = _ - @tu lazy val DottyArraysModule: Symbol = requiredModule("scala.runtime.Arrays") def newGenericArrayMethod(using Context): TermSymbol = DottyArraysModule.requiredMethod("newGenericArray") def newArrayMethod(using Context): TermSymbol = DottyArraysModule.requiredMethod("newArray") @@ -1338,10 +1327,8 @@ class Definitions { JavaImportFns :+ RootRef(() => ScalaPackageVal.termRef) - private val PredefImportFns: List[RootRef] = List( - RootRef(() => ScalaPredefModule.termRef, isPredef=true), - RootRef(() => DottyPredefModule.termRef) - ) + private val PredefImportFns: RootRef = + RootRef(() => ScalaPredefModule.termRef, isPredef=true) @tu private lazy val JavaRootImportFns: List[RootRef] = if ctx.settings.YnoImports.value then Nil @@ -1350,7 +1337,7 @@ class Definitions { @tu private lazy val ScalaRootImportFns: List[RootRef] = if ctx.settings.YnoImports.value then Nil else if ctx.settings.YnoPredef.value then ScalaImportFns - else ScalaImportFns ++ PredefImportFns + else ScalaImportFns :+ PredefImportFns @tu private lazy val JavaRootImportTypes: List[TermRef] = JavaRootImportFns.map(_.refFn()) @tu private lazy val ScalaRootImportTypes: List[TermRef] = ScalaRootImportFns.map(_.refFn()) @@ -1382,7 +1369,7 @@ class Definitions { else ScalaUnqualifiedOwnerTypes /** Names of the root import symbols that can be hidden by other imports */ - @tu lazy val ShadowableImportNames: Set[TermName] = Set("Predef", "DottyPredef").map(_.toTermName) + @tu lazy val ShadowableImportNames: Set[TermName] = Set("Predef".toTermName) /** Class symbols for which no class exist at runtime */ @tu lazy val NotRuntimeClasses: Set[Symbol] = Set(AnyClass, AnyValClass, NullClass, NothingClass) diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala index 5202fa321e83..167a3a3b3bcb 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -51,7 +51,7 @@ object ImportInfo { * @param symNameOpt Optionally, the name of the import symbol. None for root imports. * Defined for all explicit imports from ident or select nodes. * @param isRootImport true if this is one of the implicit imports of scala, java.lang, - * scala.Predef or dotty.DottyPredef in the start context, false otherwise. + * scala.Predef in the start context, false otherwise. */ class ImportInfo(symf: Context ?=> Symbol, val selectors: List[untpd.ImportSelector], diff --git a/language-server/test/dotty/tools/languageserver/CompletionTest.scala b/language-server/test/dotty/tools/languageserver/CompletionTest.scala index d58ab87b8174..049fbac09a51 100644 --- a/language-server/test/dotty/tools/languageserver/CompletionTest.scala +++ b/language-server/test/dotty/tools/languageserver/CompletionTest.scala @@ -23,7 +23,7 @@ class CompletionTest { )) } - @Test def completionFromDottyPredef: Unit = { + @Test def completionFromNewScalaPredef: Unit = { code"class Foo { val foo = summ${m1} }".withSource .completion(m1, Set(("summon", Method, "[T](using x: T): x.type"))) } diff --git a/library/src/dotty/DottyPredef.scala b/library/src-non-bootstrapped/dotty/DottyPredef.scala similarity index 100% rename from library/src/dotty/DottyPredef.scala rename to library/src-non-bootstrapped/dotty/DottyPredef.scala diff --git a/tests/neg/implicitDefs.scala b/tests/neg/implicitDefs.scala index a48d533d4d9f..7c1fcc21d7d6 100644 --- a/tests/neg/implicitDefs.scala +++ b/tests/neg/implicitDefs.scala @@ -1,6 +1,5 @@ package test -import dotty._ import Predef.{any2stringadd => _, StringAdd => _, _} object implicitDefs { diff --git a/tests/neg/nopredef.scala b/tests/neg/nopredef.scala index 6acf84600978..0079be41ee10 100644 --- a/tests/neg/nopredef.scala +++ b/tests/neg/nopredef.scala @@ -1,5 +1,4 @@ import Predef.{assert => _} -import dotty.DottyPredef.{assert => _} object Test { assert("asdf" == "asdf") // error: not found assert diff --git a/tests/neg/rootImplicits.scala b/tests/neg/rootImplicits.scala index f527333b5a9f..f2f39392597f 100644 --- a/tests/neg/rootImplicits.scala +++ b/tests/neg/rootImplicits.scala @@ -1,6 +1,5 @@ package test -import dotty._ import Predef.{any2stringadd => _, StringAdd => _, _} object rootImplicits { diff --git a/tests/pos/depfuntype.scala b/tests/pos/depfuntype.scala index 929cb7d657e3..9446f6800196 100644 --- a/tests/pos/depfuntype.scala +++ b/tests/pos/depfuntype.scala @@ -16,7 +16,7 @@ object Test { val z = depfun3(d) val z1: d.M = z - // Reproduced here because the one from DottyPredef is lacking a parameter dependency of the return type `ev.type` + // Reproduced here because the one from Predef is lacking a parameter dependency of the return type `ev.type` inline final def implicitly[T](implicit ev: T): ev.type = ev type IDF = (x: C) ?=> x.M diff --git a/tests/pos/i6384.scala b/tests/pos/i6384.scala index 9758712cf090..345914cd62e2 100644 --- a/tests/pos/i6384.scala +++ b/tests/pos/i6384.scala @@ -11,5 +11,5 @@ type ManualLambda[a] = Tc1[a] & Tc2[a] object app extends App { implicitly[Tc1[X]] //ok implicitly[ManualLambda[X]] // ok - implicitly[Tc1[X] & Tc2[X]] // no implicit argument of type Tc1[X] & Tc2[X] was found for parameter ev of method implicitly in object DottyPredef + implicitly[Tc1[X] & Tc2[X]] // no implicit argument of type Tc1[X] & Tc2[X] was found for parameter ev of method implicitly in object Predef } diff --git a/tests/run-custom-args/tuple-cons.scala b/tests/run-custom-args/tuple-cons.scala index 3fd3b819ea12..292c8aa8889c 100644 --- a/tests/run-custom-args/tuple-cons.scala +++ b/tests/run-custom-args/tuple-cons.scala @@ -1,4 +1,3 @@ -import dotty._ object Test { def main(args: Array[String]) = { diff --git a/tests/run-staging/i7897.scala b/tests/run-staging/i7897.scala index 0abd3ce0eec2..e96f8adf737e 100644 --- a/tests/run-staging/i7897.scala +++ b/tests/run-staging/i7897.scala @@ -1,14 +1,14 @@ import scala.quoted._, staging._ -given Toolbox = Toolbox.make(getClass.getClassLoader) +object Test: + given Toolbox = Toolbox.make(getClass.getClassLoader) -val f: Array[Int] => Int = run { - val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => 6 } - println(stagedSum.show) - stagedSum -} + val f: Array[Int] => Int = run { + val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => 6 } + println(stagedSum.show) + stagedSum + } -@main -def Test = { - f.apply(Array(1, 2, 3)) // Returns 6 -} + def main(args: Array[String]) = { + f.apply(Array(1, 2, 3)) // Returns 6 + } diff --git a/tests/run-staging/i8178.scala b/tests/run-staging/i8178.scala index 57001e9a7415..b5537053a6e4 100644 --- a/tests/run-staging/i8178.scala +++ b/tests/run-staging/i8178.scala @@ -5,11 +5,12 @@ def foo(n: Int, t: Expr[Int])(using Quotes): Expr[Int] = if (n == 0) t else '{ val a = ${Expr(n)}; ${foo(n - 1, 'a)} + $t } -@main def Test = { - // make available the necessary toolbox for runtime code generation - given Toolbox = Toolbox.make(getClass.getClassLoader) +object Test: + def main(args: Array[String]) = { + // make available the necessary toolbox for runtime code generation + given Toolbox = Toolbox.make(getClass.getClassLoader) - val f: Int = run { foo(2, Expr(5)) } + val f: Int = run { foo(2, Expr(5)) } - println(f) -} + println(f) + } diff --git a/tests/run/tuple-accessors.scala b/tests/run/tuple-accessors.scala index 897b40bbcf2f..0931babf00a8 100644 --- a/tests/run/tuple-accessors.scala +++ b/tests/run/tuple-accessors.scala @@ -1,4 +1,3 @@ -import dotty._ case class X2[A, B](a: A, b: B) case class X3[A, B, C](a: A, b: B, c: C) diff --git a/tests/run/tuple-underscore-syntax.scala b/tests/run/tuple-underscore-syntax.scala index 497b3d0b0ae9..ce71440058d0 100644 --- a/tests/run/tuple-underscore-syntax.scala +++ b/tests/run/tuple-underscore-syntax.scala @@ -1,4 +1,3 @@ -import dotty._ object Test { def main(args: Array[String]) = {