Skip to content

Commit 90aea07

Browse files
committed
Initial pre-change cleanups
1 parent ca7bd7d commit 90aea07

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/Definitions.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -535,17 +535,18 @@ class Definitions {
535535
List(AnyType), EmptyScope)
536536
@tu lazy val SingletonType: TypeRef = SingletonClass.typeRef
537537

538-
@tu lazy val CollectionSeqType: TypeRef = requiredClassRef("scala.collection.Seq")
539-
@tu lazy val SeqType: TypeRef = requiredClassRef("scala.collection.immutable.Seq")
538+
@tu lazy val CollectionSeqType: TypeRef = requiredClassRef("scala.collection.Seq")
539+
@tu lazy val SeqType: TypeRef = requiredClassRef("scala.collection.immutable.Seq")
540+
@tu lazy val SeqModule: Symbol = requiredModule("scala.collection.immutable.Seq")
541+
@tu lazy val SeqModule_apply: Symbol = SeqModule.requiredMethod(nme.apply)
542+
def SeqModuleAlias: Symbol = ScalaPackageClass.requiredMethod(nme.Seq)
540543
def SeqClass(using Context): ClassSymbol = SeqType.symbol.asClass
541544
@tu lazy val Seq_apply : Symbol = SeqClass.requiredMethod(nme.apply)
542545
@tu lazy val Seq_head : Symbol = SeqClass.requiredMethod(nme.head)
543546
@tu lazy val Seq_drop : Symbol = SeqClass.requiredMethod(nme.drop)
544547
@tu lazy val Seq_lengthCompare: Symbol = SeqClass.requiredMethod(nme.lengthCompare, List(IntType))
545548
@tu lazy val Seq_length : Symbol = SeqClass.requiredMethod(nme.length)
546549
@tu lazy val Seq_toSeq : Symbol = SeqClass.requiredMethod(nme.toSeq)
547-
@tu lazy val SeqModule : Symbol = requiredModule("scala.collection.immutable.Seq")
548-
@tu lazy val SeqModule_apply : Symbol = SeqModule.requiredMethod(nme.apply)
549550

550551

551552
@tu lazy val StringOps: Symbol = requiredClass("scala.collection.StringOps")

Diff for: compiler/src/dotty/tools/dotc/transform/ArrayApply.scala

+13-24
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
package dotty.tools.dotc
1+
package dotty.tools
2+
package dotc
23
package transform
34

4-
import core.*
5+
import ast.tpd
6+
import core.*, Contexts.*, Decorators.*, Symbols.*, Flags.*, StdNames.*
7+
import reporting.trace
58
import 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

Comments
 (0)