File tree 2 files changed +8
-9
lines changed
compiler/src/dotty/tools/dotc 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import scala.collection.{ mutable, immutable }
9
9
import PartialFunction ._
10
10
import collection .mutable
11
11
import util .common .alwaysZero
12
+ import dotty .tools .dotc .transform .TreeGen
12
13
13
14
object Definitions {
14
15
@@ -338,6 +339,12 @@ class Definitions {
338
339
def Predef_classOf (implicit ctx : Context ) = Predef_classOfR .symbol
339
340
lazy val Predef_undefinedR = ScalaPredefModule .requiredMethodRef(" ???" )
340
341
def Predef_undefined (implicit ctx : Context ) = Predef_undefinedR .symbol
342
+ // The set of all wrap{X, Ref}Array methods, where X is a value type
343
+ lazy val Predef_wrapArrayR : Set [TermRef ] = {
344
+ val methodNames = ScalaValueTypes .map(TreeGen .wrapArrayMethodName) + nme.wrapRefArray
345
+ methodNames.map(ScalaPredefModule .requiredMethodRef).toSet
346
+ }
347
+ def Predef_wrapArray (implicit ctx : Context ): Set [Symbol ] = Predef_wrapArrayR .map(_.symbol)
341
348
342
349
lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef(" scala.runtime.ScalaRunTime" )
343
350
def ScalaRuntimeModule (implicit ctx : Context ) = ScalaRuntimeModuleRef .symbol
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
94
94
private def seqToArray (tree : Tree , pt : Type )(implicit ctx : Context ): Tree = tree match {
95
95
case SeqLiteral (elems, elemtpt) =>
96
96
JavaSeqLiteral (elems, elemtpt)
97
- case app@ Apply (fun, args) if isWrappedArray(app ) => // rewrite a call to `wrapXArray(arr)` to `arr`
97
+ case app@ Apply (fun, args) if defn. Predef_wrapArray .contains(fun.symbol ) => // rewrite a call to `wrapXArray(arr)` to `arr`
98
98
args.head
99
99
case _ =>
100
100
val elemType = tree.tpe.elemType
@@ -108,14 +108,6 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
108
108
// Because of phantomclasses, the Java array's type might not conform to the return type
109
109
}
110
110
111
- /** Determines whether `tree` is a method call to Predef.wrapXArray */
112
- private def isWrappedArray (tree : Apply )(implicit ctx : Context ): Boolean = {
113
- val elemTpe = tree.tpe.elemType
114
- val wrapMethodName = TreeGen .wrapArrayMethodName(elemTpe)
115
- val wrapMethodSym = defn.ScalaPredefModuleRef .denot.requiredMethod(wrapMethodName)
116
- tree.fun.symbol == wrapMethodSym
117
- }
118
-
119
111
override def transformTypeApply (tree : TypeApply )(implicit ctx : Context ): Tree =
120
112
transformTypeOfTree(tree)
121
113
You can’t perform that action at this time.
0 commit comments