File tree 2 files changed +12
-9
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,19 @@ object ResolveSuper {
103
103
val other = bcs.head.info.nonPrivateDecl(memberName)
104
104
if (ctx.settings.Ydebug .value)
105
105
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
113
107
bcs = bcs.tail
114
108
}
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)
115
119
assert(sym.exists)
116
120
sym
117
121
}
Original file line number Diff line number Diff line change @@ -14,8 +14,7 @@ trait C extends A[Y] {
14
14
def superFoo : Y = super .foo // C will have an abstract `def C$$super$foo: Y` because of this call
15
15
}
16
16
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
19
18
20
19
object Test {
21
20
def main (args : Array [String ]): Unit = {
You can’t perform that action at this time.
0 commit comments