Skip to content

Commit 3f51f11

Browse files
committed
Move ElimRepeated miniphase to an earlier group
ByNameLambda needs to run in a group after ElimRepeated since ElimRepeated works on ByName arguments but not converted closures, and it sees the arguments after transformations by subsequent miniphases in the same group.
1 parent a447a7e commit 3f51f11

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ class Compiler {
6767
new CheckLoopingImplicits, // Check that implicit defs do not call themselves in an infinite loop
6868
new BetaReduce, // Reduce closure applications
6969
new InlineVals, // Check right hand-sides of an `inline val`s
70-
new ExpandSAMs) :: // Expand single abstract method closures to anonymous classes
70+
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
71+
new ElimRepeated) :: // Rewrite vararg parameters and arguments
7172
List(new init.Checker) :: // Check initialization of objects
72-
List(new ElimRepeated, // Rewrite vararg parameters and arguments
73-
new ByNameLambda, // Replace by-name applications with closures
73+
List(new ByNameLambda, // Replace by-name applications with closures
7474
new ProtectedAccessors, // Add accessors for protected members
7575
new ExtensionMethods, // Expand methods of value classes with extension methods
7676
new UncacheGivenAliases, // Avoid caching RHS of simple parameterless given aliases

compiler/src/dotty/tools/dotc/transform/ByNameLambda.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class ByNameLambda extends MiniPhase, IdentityDenotTransformer:
1818

1919
def phaseName: String = ByNameLambda.name
2020

21+
override def runsAfterGroupsOf: Set[String] = Set(ElimRepeated.name)
22+
// ByNameLambda needs to run in a group after ElimRepeated since ElimRepeated
23+
// works on ByName arguments but not converted closures, and it sees the arguments
24+
// after transformations by subsequent miniphases in the same group.
25+
2126
override def transformApply(app: Apply)(using Context): Tree = app match
2227
case ByName(body) =>
2328
body match

0 commit comments

Comments
 (0)