Skip to content

Commit 4c5988f

Browse files
committed
Another fix to ElimOpaque
We also need to undo the RefinedType self type of opaque type companions. Otherwise, programs die in erasure if tracing is enabled.
1 parent 8e2221d commit 4c5988f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ class ElimOpaque extends MiniPhase with DenotTransformer {
3636
info = TypeAlias(ref.opaqueAlias),
3737
initFlags = ref.flags &~ (Opaque | Deferred))
3838
case ref: SymDenotation if sym.isOpaqueCompanion =>
39-
val ref1 = ref.copySymDenotation(initFlags = ref.flags &~ Opaque)
39+
val cinfo = sym.asClass.classInfo
40+
val RefinedType(sourceRef, _, _) = cinfo.selfInfo
41+
val ref1 = ref.copySymDenotation(
42+
info = cinfo.derivedClassInfo(selfInfo = sourceRef),
43+
initFlags = ref.flags &~ Opaque)
4044
ref1.registeredCompanion = NoSymbol
4145
ref1
4246
case _ if sym.isOpaqueHelper =>

0 commit comments

Comments
 (0)