Skip to content

Commit

Permalink
Merge pull request #10706 from dotty-staging/remove-DottyPredef
Browse files Browse the repository at this point in the history
  • Loading branch information
smarter committed Dec 10, 2020
2 parents 2457371 + 6d7b79c commit 51ac3ae
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 43 deletions.
21 changes: 4 additions & 17 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
}
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion tests/neg/implicitDefs.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test

import dotty._
import Predef.{any2stringadd => _, StringAdd => _, _}

object implicitDefs {
Expand Down
1 change: 0 additions & 1 deletion tests/neg/nopredef.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Predef.{assert => _}
import dotty.DottyPredef.{assert => _}

object Test {
assert("asdf" == "asdf") // error: not found assert
Expand Down
1 change: 0 additions & 1 deletion tests/neg/rootImplicits.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package test

import dotty._
import Predef.{any2stringadd => _, StringAdd => _, _}

object rootImplicits {
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/depfuntype.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i6384.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 0 additions & 1 deletion tests/run-custom-args/tuple-cons.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dotty._

object Test {
def main(args: Array[String]) = {
Expand Down
20 changes: 10 additions & 10 deletions tests/run-staging/i7897.scala
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 7 additions & 6 deletions tests/run-staging/i8178.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 0 additions & 1 deletion tests/run/tuple-accessors.scala
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/run/tuple-underscore-syntax.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dotty._

object Test {
def main(args: Array[String]) = {
Expand Down

0 comments on commit 51ac3ae

Please sign in to comment.