Skip to content

Commit 0f3de61

Browse files
committed
Fix #9267: Avoid accessing inexistent next phase
* Only compute `elimErasedCtx` when error is emitted * Fall back to erasure context if it is the last phase
1 parent baba3f0 commit 0f3de61

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(implicit ctx: Cont
1616

1717
assert(ctx.phase == ctx.erasurePhase.next)
1818
private val preErasureCtx = ctx.withPhase(ctx.erasurePhase)
19-
private val elimErasedCtx = ctx.withPhase(ctx.elimErasedValueTypePhase.next)
19+
private def elimErasedCtx = ctx.withPhase(
20+
if ctx.elimErasedValueTypePhase.exists then ctx.elimErasedValueTypePhase.next
21+
else ctx.erasurePhase.next // can happen with -Ystop-after:erasure
22+
)
2023

2124
private class BridgesCursor(implicit ctx: Context) extends OverridingPairs.Cursor(root) {
2225

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CompilationTests extends ParallelTesting {
6565
compileFile("tests/run/i5606.scala", defaultOptions.and("-Yretain-trees")),
6666
compileFile("tests/pos-custom-args/i5498-postfixOps.scala", defaultOptions withoutLanguageFeature "postfixOps"),
6767
compileFile("tests/pos-custom-args/i8875.scala", defaultOptions.and("-Xprint:getters")),
68+
compileFile("tests/pos-custom-args/i9267.scala", defaultOptions.and("-Ystop-after:erasure")),
6869
).checkCompile()
6970
}
7071

tests/pos-custom-args/i9267.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class A

0 commit comments

Comments
 (0)