Skip to content

Commit 12be929

Browse files
committed
Fix #2901: Make asClass cast lazy in case of previous errors
1 parent 4f60767 commit 12be929

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
101101
val Select(sup @ Super(_, mix), name) = sel
102102
val sym = sel.symbol
103103
assert(sup.symbol.exists, s"missing symbol in $sel: ${sup.tpe}")
104-
val clazz = sup.symbol.asClass
104+
lazy val clazz = sup.symbol.asClass
105105

106106
if (sym.isTerm && !sym.is(Method, butNot = Accessor) && !ctx.owner.is(ParamForwarder))
107107
// ParamForwaders as installed ParamForwarding.scala do use super calls to vals

tests/neg/i2901.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo {
2+
def foo = 4
3+
}
4+
object Bar extends Foo {
5+
inline def bar = super[Foo].foo // error
6+
}
7+
object Main {
8+
Bar.bar
9+
}

0 commit comments

Comments
 (0)