diff --git a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala index 825b2ff43e88..9a505ce8d49e 100644 --- a/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala +++ b/compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala @@ -101,7 +101,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) { val Select(sup @ Super(_, mix), name) = sel val sym = sel.symbol assert(sup.symbol.exists, s"missing symbol in $sel: ${sup.tpe}") - val clazz = sup.symbol.asClass + val clazz = sup.symbol if (sym.isTerm && !sym.is(Method, butNot = Accessor) && !ctx.owner.is(ParamForwarder)) // ParamForwaders as installed ParamForwarding.scala do use super calls to vals @@ -109,7 +109,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) { else if (isDisallowed(sym)) ctx.error(s"super not allowed here: use this.${sel.name} instead", sel.pos) else if (sym is Deferred) { - val member = sym.overridingSymbol(clazz) + val member = sym.overridingSymbol(clazz.asClass) if (!mix.name.isEmpty || !member.exists || !((member is AbsOverride) && member.isIncompleteIn(clazz))) diff --git a/tests/neg/i2901.scala b/tests/neg/i2901.scala new file mode 100644 index 000000000000..9c9ff616d205 --- /dev/null +++ b/tests/neg/i2901.scala @@ -0,0 +1,9 @@ +trait Foo { + def foo = 4 +} +object Bar extends Foo { + inline def bar = super[Foo].foo // error +} +object Main { + Bar.bar +}