Skip to content

Commit 51ac3ae

Browse files
authored
Merge pull request #10706 from dotty-staging/remove-DottyPredef
2 parents 2457371 + 6d7b79c commit 51ac3ae

File tree

14 files changed

+25
-43
lines changed

14 files changed

+25
-43
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,6 @@ class Definitions {
497497
def staticsMethodRef(name: PreName): TermRef = ScalaStaticsModule.requiredMethodRef(name)
498498
def staticsMethod(name: PreName): TermSymbol = ScalaStaticsModule.requiredMethod(name)
499499

500-
// Dotty deviation: we cannot use a @tu lazy val here because @tu lazy vals in dotty
501-
// will return "null" when called recursively, see #1856.
502-
def DottyPredefModule: Symbol = {
503-
if (myDottyPredefModule == null) {
504-
myDottyPredefModule = getModuleIfDefined("dotty.DottyPredef")
505-
assert(myDottyPredefModule != null)
506-
}
507-
myDottyPredefModule
508-
}
509-
private var myDottyPredefModule: Symbol = _
510-
511500
@tu lazy val DottyArraysModule: Symbol = requiredModule("scala.runtime.Arrays")
512501
def newGenericArrayMethod(using Context): TermSymbol = DottyArraysModule.requiredMethod("newGenericArray")
513502
def newArrayMethod(using Context): TermSymbol = DottyArraysModule.requiredMethod("newArray")
@@ -1338,10 +1327,8 @@ class Definitions {
13381327
JavaImportFns :+
13391328
RootRef(() => ScalaPackageVal.termRef)
13401329

1341-
private val PredefImportFns: List[RootRef] = List(
1342-
RootRef(() => ScalaPredefModule.termRef, isPredef=true),
1343-
RootRef(() => DottyPredefModule.termRef)
1344-
)
1330+
private val PredefImportFns: RootRef =
1331+
RootRef(() => ScalaPredefModule.termRef, isPredef=true)
13451332

13461333
@tu private lazy val JavaRootImportFns: List[RootRef] =
13471334
if ctx.settings.YnoImports.value then Nil
@@ -1350,7 +1337,7 @@ class Definitions {
13501337
@tu private lazy val ScalaRootImportFns: List[RootRef] =
13511338
if ctx.settings.YnoImports.value then Nil
13521339
else if ctx.settings.YnoPredef.value then ScalaImportFns
1353-
else ScalaImportFns ++ PredefImportFns
1340+
else ScalaImportFns :+ PredefImportFns
13541341

13551342
@tu private lazy val JavaRootImportTypes: List[TermRef] = JavaRootImportFns.map(_.refFn())
13561343
@tu private lazy val ScalaRootImportTypes: List[TermRef] = ScalaRootImportFns.map(_.refFn())
@@ -1382,7 +1369,7 @@ class Definitions {
13821369
else ScalaUnqualifiedOwnerTypes
13831370

13841371
/** Names of the root import symbols that can be hidden by other imports */
1385-
@tu lazy val ShadowableImportNames: Set[TermName] = Set("Predef", "DottyPredef").map(_.toTermName)
1372+
@tu lazy val ShadowableImportNames: Set[TermName] = Set("Predef".toTermName)
13861373

13871374
/** Class symbols for which no class exist at runtime */
13881375
@tu lazy val NotRuntimeClasses: Set[Symbol] = Set(AnyClass, AnyValClass, NullClass, NothingClass)

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object ImportInfo {
5151
* @param symNameOpt Optionally, the name of the import symbol. None for root imports.
5252
* Defined for all explicit imports from ident or select nodes.
5353
* @param isRootImport true if this is one of the implicit imports of scala, java.lang,
54-
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
54+
* scala.Predef in the start context, false otherwise.
5555
*/
5656
class ImportInfo(symf: Context ?=> Symbol,
5757
val selectors: List[untpd.ImportSelector],

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CompletionTest {
2323
))
2424
}
2525

26-
@Test def completionFromDottyPredef: Unit = {
26+
@Test def completionFromNewScalaPredef: Unit = {
2727
code"class Foo { val foo = summ${m1} }".withSource
2828
.completion(m1, Set(("summon", Method, "[T](using x: T): x.type")))
2929
}

tests/neg/implicitDefs.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package test
22

3-
import dotty._
43
import Predef.{any2stringadd => _, StringAdd => _, _}
54

65
object implicitDefs {

tests/neg/nopredef.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Predef.{assert => _}
2-
import dotty.DottyPredef.{assert => _}
32

43
object Test {
54
assert("asdf" == "asdf") // error: not found assert

tests/neg/rootImplicits.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package test
22

3-
import dotty._
43
import Predef.{any2stringadd => _, StringAdd => _, _}
54

65
object rootImplicits {

tests/pos/depfuntype.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Test {
1616
val z = depfun3(d)
1717
val z1: d.M = z
1818

19-
// Reproduced here because the one from DottyPredef is lacking a parameter dependency of the return type `ev.type`
19+
// Reproduced here because the one from Predef is lacking a parameter dependency of the return type `ev.type`
2020
inline final def implicitly[T](implicit ev: T): ev.type = ev
2121

2222
type IDF = (x: C) ?=> x.M

tests/pos/i6384.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ type ManualLambda[a] = Tc1[a] & Tc2[a]
1111
object app extends App {
1212
implicitly[Tc1[X]] //ok
1313
implicitly[ManualLambda[X]] // ok
14-
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
14+
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
1515
}

tests/run-custom-args/tuple-cons.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dotty._
21

32
object Test {
43
def main(args: Array[String]) = {

tests/run-staging/i7897.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import scala.quoted._, staging._
22

3-
given Toolbox = Toolbox.make(getClass.getClassLoader)
3+
object Test:
4+
given Toolbox = Toolbox.make(getClass.getClassLoader)
45

5-
val f: Array[Int] => Int = run {
6-
val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => 6 }
7-
println(stagedSum.show)
8-
stagedSum
9-
}
6+
val f: Array[Int] => Int = run {
7+
val stagedSum: Expr[Array[Int] => Int] = '{ (arr: Array[Int]) => 6 }
8+
println(stagedSum.show)
9+
stagedSum
10+
}
1011

11-
@main
12-
def Test = {
13-
f.apply(Array(1, 2, 3)) // Returns 6
14-
}
12+
def main(args: Array[String]) = {
13+
f.apply(Array(1, 2, 3)) // Returns 6
14+
}

tests/run-staging/i8178.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ def foo(n: Int, t: Expr[Int])(using Quotes): Expr[Int] =
55
if (n == 0) t
66
else '{ val a = ${Expr(n)}; ${foo(n - 1, 'a)} + $t }
77

8-
@main def Test = {
9-
// make available the necessary toolbox for runtime code generation
10-
given Toolbox = Toolbox.make(getClass.getClassLoader)
8+
object Test:
9+
def main(args: Array[String]) = {
10+
// make available the necessary toolbox for runtime code generation
11+
given Toolbox = Toolbox.make(getClass.getClassLoader)
1112

12-
val f: Int = run { foo(2, Expr(5)) }
13+
val f: Int = run { foo(2, Expr(5)) }
1314

14-
println(f)
15-
}
15+
println(f)
16+
}

tests/run/tuple-accessors.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dotty._
21

32
case class X2[A, B](a: A, b: B)
43
case class X3[A, B, C](a: A, b: B, c: C)

tests/run/tuple-underscore-syntax.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dotty._
21

32
object Test {
43
def main(args: Array[String]) = {

0 commit comments

Comments
 (0)