Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ 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
ctx.error(s"super may be not be used on ${sym.underlyingSymbol}", sel.pos)
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)))
Expand Down
9 changes: 9 additions & 0 deletions tests/neg/i2901.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
trait Foo {
def foo = 4
}
object Bar extends Foo {
inline def bar = super[Foo].foo // error
}
object Main {
Bar.bar
}