File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,19 @@ object ResolveSuper {
103103 val other = bcs.head.info.nonPrivateDecl(memberName)
104104 if (ctx.settings.Ydebug .value)
105105 ctx.log(i " rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred )}" )
106- val otherMember = other.matchingDenotation(base.thisType, base.thisType.memberInfo(acc))
107-
108- // Having a matching denotation is not enough: it should also be a subtype
109- // of the superaccessor's type, see i5433.scala for an example where this matters
110- if (otherMember.asSeenFrom(base.typeRef).info <:< acc.asSeenFrom(base.typeRef).info)
111- sym = otherMember.symbol
112-
106+ sym = other.matchingDenotation(base.thisType, base.thisType.memberInfo(acc)).symbol
113107 bcs = bcs.tail
114108 }
109+ // Having a matching denotation is not enough: it should also be a subtype
110+ // of the superaccessor's type, see i5433.scala for an example where this matters
111+ if (! (sym.asSeenFrom(base.typeRef).info <:< acc.asSeenFrom(base.typeRef).info))
112+ ctx.error(em """ illegal mixin super call target:
113+ |
114+ | ${sym.showDcl} in ${sym.owner}
115+ |
116+ |does not conform to expected target type
117+ |
118+ | ${acc.info}""" , base.pos)
115119 assert(sym.exists)
116120 sym
117121 }
Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ trait C extends A[Y] {
1414 def superFoo : Y = super .foo // C will have an abstract `def C$$super$foo: Y` because of this call
1515}
1616
17- class Fail extends B with C
18- // Should generate `def C$$super$foo: Y = super[A].foo` and not `= super[B].foo`
17+ class Fail extends B with C // error: illegal mixin super call target
1918
2019object Test {
2120 def main (args : Array [String ]): Unit = {
You can’t perform that action at this time.
0 commit comments