1- package dotty .tools .dotc
1+ package dotty .tools
2+ package dotc
23package transform
34
4- import core .*
5+ import ast .tpd
6+ import core .* , Contexts .* , Decorators .* , Symbols .* , Flags .* , StdNames .*
7+ import reporting .trace
58import MegaPhase .*
6- import Contexts .*
7- import Symbols .*
8- import Flags .*
9- import StdNames .*
10- import dotty .tools .dotc .ast .tpd
11-
12-
139
1410/** This phase rewrites calls to `Array.apply` to a direct instantiation of the array in the bytecode.
1511 *
@@ -22,37 +18,30 @@ class ArrayApply extends MiniPhase {
2218
2319 override def description : String = ArrayApply .description
2420
25- private var transformListApplyLimit = 8
26-
27- private def reducingTransformListApply [A ](depth : Int )(body : => A ): A = {
28- val saved = transformListApplyLimit
29- transformListApplyLimit -= depth
30- try body
31- finally transformListApplyLimit = saved
32- }
21+ private val transformListApplyLimit = 8
3322
34- override def transformApply (tree : tpd. Apply )(using Context ): tpd. Tree =
23+ override def transformApply (tree : Apply )(using Context ): Tree =
3524 if isArrayModuleApply(tree.symbol) then
3625 tree.args match
37- case StripAscription (Apply (wrapRefArrayMeth, (seqLit : tpd. JavaSeqLiteral ) :: Nil )) :: ct :: Nil
26+ case StripAscription (Apply (wrapRefArrayMeth, (seqLit : JavaSeqLiteral ) :: Nil )) :: ct :: Nil
3827 if defn.WrapArrayMethods ().contains(wrapRefArrayMeth.symbol) && elideClassTag(ct) =>
3928 seqLit
4029
41- case elem0 :: StripAscription (Apply (wrapRefArrayMeth, (seqLit : tpd. JavaSeqLiteral ) :: Nil )) :: Nil
30+ case elem0 :: StripAscription (Apply (wrapRefArrayMeth, (seqLit : JavaSeqLiteral ) :: Nil )) :: Nil
4231 if defn.WrapArrayMethods ().contains(wrapRefArrayMeth.symbol) =>
43- tpd. JavaSeqLiteral (elem0 :: seqLit.elems, seqLit.elemtpt)
32+ JavaSeqLiteral (elem0 :: seqLit.elems, seqLit.elemtpt)
4433
4534 case _ =>
4635 tree
4736
4837 else if isListOrSeqModuleApply(tree.symbol) then
4938 tree.args match
5039 // <List or Seq>(a, b, c) ~> new ::(a, new ::(b, new ::(c, Nil))) but only for reference types
51- case StripAscription (Apply (wrapArrayMeth, List (StripAscription (rest : tpd. JavaSeqLiteral )))) :: Nil
40+ case StripAscription (Apply (wrapArrayMeth, List (StripAscription (rest : JavaSeqLiteral )))) :: Nil
5241 if defn.WrapArrayMethods ().contains(wrapArrayMeth.symbol) &&
5342 rest.elems.lengthIs < transformListApplyLimit =>
54- rest.elems.foldRight(tpd. ref(defn.NilModule )): (elem, acc) =>
55- tpd. New (defn.ConsType , List (elem.ensureConforms(defn.ObjectType ), acc))
43+ rest.elems.foldRight(ref(defn.NilModule )): (elem, acc) =>
44+ New (defn.ConsType , List (elem.ensureConforms(defn.ObjectType ), acc))
5645
5746 case _ =>
5847 tree
0 commit comments