Skip to content

Commit ee19855

Browse files
authored
Merge pull request #8589 from dotty-staging/fix-#8582
Fix #8582: Don't resolve super to abstract members
2 parents 6089e1d + 739aebb commit ee19855

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,14 @@ object ResolveSuper {
8686
val other = bcs.head.info.nonPrivateDecl(memberName)
8787
.matchingDenotation(base.thisType, base.thisType.memberInfo(acc))
8888
ctx.debuglog(i"rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred)}")
89-
if (other.exists) {
89+
if other.exists && !other.symbol.is(Deferred) then
9090
sym = other.symbol
9191
// Having a matching denotation is not enough: it should also be a subtype
9292
// of the superaccessor's type, see i5433.scala for an example where this matters
9393
val otherTp = other.asSeenFrom(base.typeRef).info
9494
val accTp = acc.asSeenFrom(base.typeRef).info
9595
if (!(otherTp.overrides(accTp, matchLoosely = true)))
9696
ctx.error(IllegalSuperAccessor(base, memberName, acc, accTp, other.symbol, otherTp), base.sourcePos)
97-
}
9897

9998
bcs = bcs.tail
10099
}

tests/run/i8582.check

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

tests/run/i8582.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trait Suite {
2+
def run() = println("Suite")
3+
}
4+
trait SuiteMixin { this: Suite =>
5+
def run(): Unit
6+
}
7+
trait BeforeAndAfterAll extends SuiteMixin { this: Suite =>
8+
abstract override def run() = super.run()
9+
}
10+
class MySpec extends Suite with BeforeAndAfterAll
11+
object Test {
12+
def main(args: Array[String]): Unit = {
13+
new MySpec().run()
14+
}
15+
}

0 commit comments

Comments
 (0)