@@ -9,7 +9,6 @@ import scala.collection.{ mutable, immutable }
99import PartialFunction ._
1010import collection .mutable
1111import util .common .alwaysZero
12- import dotty .tools .dotc .transform .TreeGen
1312
1413object Definitions {
1514
@@ -345,11 +344,6 @@ class Definitions {
345344 def Predef_classOf (implicit ctx : Context ) = Predef_classOfR .symbol
346345 lazy val Predef_undefinedR = ScalaPredefModule .requiredMethodRef(" ???" )
347346 def Predef_undefined (implicit ctx : Context ) = Predef_undefinedR .symbol
348- // The set of all wrap{X, Ref}Array methods, where X is a value type
349- val Predef_wrapArray = new PerRun [collection.Set [Symbol ]]({ implicit ctx =>
350- val methodNames = ScalaValueTypes .map(TreeGen .wrapArrayMethodName) + nme.wrapRefArray
351- methodNames.map(ScalaPredefModule .requiredMethodRef(_).symbol)
352- })
353347
354348 lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef(" scala.runtime.ScalaRunTime" )
355349 def ScalaRuntimeModule (implicit ctx : Context ) = ScalaRuntimeModuleRef .symbol
@@ -390,6 +384,17 @@ class Definitions {
390384 def newGenericArrayMethod (implicit ctx : Context ) = DottyArraysModule .requiredMethod(" newGenericArray" )
391385 def newArrayMethod (implicit ctx : Context ) = DottyArraysModule .requiredMethod(" newArray" )
392386
387+ // TODO: Remove once we drop support for 2.12 standard library
388+ private [this ] lazy val isNewCollections = ctx.base.staticRef(" scala.collection.IterableOnce" .toTypeName).exists
389+
390+ def getWrapVarargsArrayModule = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule
391+
392+ // The set of all wrap{X, Ref}Array methods, where X is a value type
393+ val WrapArrayMethods = new PerRun [collection.Set [Symbol ]]({ implicit ctx =>
394+ val methodNames = ScalaValueTypes .map(ast.tpd.wrapArrayMethodName) + nme.wrapRefArray
395+ methodNames.map(getWrapVarargsArrayModule.requiredMethodRef(_).symbol)
396+ })
397+
393398 lazy val NilModuleRef = ctx.requiredModuleRef(" scala.collection.immutable.Nil" )
394399 def NilModule (implicit ctx : Context ) = NilModuleRef .symbol
395400
@@ -401,7 +406,9 @@ class Definitions {
401406 List (AnyClass .typeRef), EmptyScope )
402407 lazy val SingletonType : TypeRef = SingletonClass .typeRef
403408
404- lazy val SeqType : TypeRef = ctx.requiredClassRef(" scala.collection.Seq" )
409+ lazy val SeqType : TypeRef =
410+ if (isNewCollections) ctx.requiredClassRef(" scala.collection.immutable.Seq" )
411+ else ctx.requiredClassRef(" scala.collection.Seq" )
405412 def SeqClass (implicit ctx : Context ) = SeqType .symbol.asClass
406413 lazy val Seq_applyR = SeqClass .requiredMethodRef(nme.apply)
407414 def Seq_apply (implicit ctx : Context ) = Seq_applyR .symbol
@@ -1210,12 +1217,11 @@ class Definitions {
12101217
12111218 lazy val reservedScalaClassNames : Set [Name ] = syntheticScalaClasses.map(_.name).toSet
12121219
1213- private [this ] var _isInitialized = false
1214- private def isInitialized = _isInitialized
1220+ private [this ] var isInitialized = false
12151221
12161222 def init ()(implicit ctx : Context ) = {
12171223 this .ctx = ctx
1218- if (! _isInitialized ) {
1224+ if (! isInitialized ) {
12191225 // Enter all symbols from the scalaShadowing package in the scala package
12201226 for (m <- ScalaShadowingPackageClass .info.decls)
12211227 ScalaPackageClass .enter(m)
@@ -1230,7 +1236,7 @@ class Definitions {
12301236 // force initialization of every symbol that is synthesized or hijacked by the compiler
12311237 val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
12321238
1233- _isInitialized = true
1239+ isInitialized = true
12341240 }
12351241 }
12361242
0 commit comments