Skip to content

Commit 437e86a

Browse files
Don't run problematic optimisations AfterErasure
1 parent 965e807 commit 437e86a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

compiler/src/dotty/tools/dotc/transform/linker/Simplify.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
273273
else a
274274
case t => t
275275
}
276-
("inlineCaseIntrinsics", BeforeAndAfterErasure, NoVisitor, transformer)
276+
// To run this optimisation after erasure one would need to specialize it
277+
// for constructor with outer pointer and values classes. There is probably
278+
// no need to run this more than once.
279+
("inlineCaseIntrinsics", BeforeErasure, NoVisitor, transformer)
277280
}
278281

279282
/** Various constant folding.
@@ -811,8 +814,8 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
811814
(t.symbol.is(CaseAccessor) && !t.symbol.is(Mutable)) =>
812815
keepOnlySideEffects(rec) // Accessing a field of a product
813816
case s @ Select(qual, name) if
814-
!name.eq(nme.TYPE_) && // Keep the .TYPE added by ClassOf
815-
!t.symbol.is(Flags.Mutable | Flags.Lazy) && !t.symbol.is(Flags.Method) =>
817+
// !name.eq(nme.TYPE_) && // Keep the .TYPE added by ClassOf, would be needed for AfterErasure
818+
!t.symbol.is(Mutable | Lazy) && !t.symbol.is(Method) =>
816819
keepOnlySideEffects(qual)
817820
case Block(List(t: DefDef), s: Closure) =>
818821
EmptyTree
@@ -905,7 +908,8 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
905908
} else a
906909
case t => t
907910
}
908-
("dropNoEffects", BeforeAndAfterErasure, NoVisitor, transformer)
911+
// BoxedUnit messes up this phase after erasure
912+
("dropNoEffects", BeforeErasure, NoVisitor, transformer)
909913
}
910914

911915
/** Inlines LabelDef which are used exactly once. */
@@ -945,7 +949,7 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
945949
EmptyTree
946950
case t => t
947951
}
948-
("inlineLabelsCalledOnce", BeforeAndAfterErasure, visitor, transformer)
952+
("inlineLabelsCalledOnce", BeforeErasure, visitor, transformer)
949953
}
950954

951955
/** Rewrites pairs of consecutive LabelDef jumps by jumping directly to the target. */

0 commit comments

Comments
 (0)