@@ -101,37 +101,42 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
101
101
val Select (sup @ Super (_, mix), name) = sel
102
102
val sym = sel.symbol
103
103
assert(sup.symbol.exists, s " missing symbol in $sel: ${sup.tpe}" )
104
- lazy val clazz = sup.symbol.asClass
105
104
106
- if (sym.isTerm && ! sym.is(Method , butNot = Accessor ) && ! ctx.owner.is(ParamForwarder ))
105
+ if (sym.isTerm && ! sym.is(Method , butNot = Accessor ) && ! ctx.owner.is(ParamForwarder )) {
107
106
// ParamForwaders as installed ParamForwarding.scala do use super calls to vals
108
107
ctx.error(s " super may be not be used on ${sym.underlyingSymbol}" , sel.pos)
109
- else if (isDisallowed(sym))
108
+ sel
109
+ } else if (isDisallowed(sym)) {
110
110
ctx.error(s " super not allowed here: use this. ${sel.name} instead " , sel.pos)
111
- else if (sym is Deferred ) {
112
- val member = sym.overridingSymbol(clazz)
113
- if (! mix.name.isEmpty ||
111
+ sel
112
+ } else {
113
+ val clazz = sup.symbol.asClass
114
+ if (sym is Deferred ) {
115
+ val member = sym.overridingSymbol(clazz)
116
+ if (! mix.name.isEmpty ||
114
117
! member.exists ||
115
118
! ((member is AbsOverride ) && member.isIncompleteIn(clazz)))
116
- ctx.error(
119
+ ctx.error(
117
120
i " ${sym.showLocated} is accessed from super. It may not be abstract unless it is overridden by a member declared `abstract' and `override' " ,
118
121
sel.pos)
119
- else ctx.log(i " ok super $sel ${sym.showLocated} $member $clazz ${member.isIncompleteIn(clazz)}" )
120
- }
121
- else if (mix.name.isEmpty && ! (sym.owner is Trait ))
122
+ else ctx.log(i " ok super $sel ${sym.showLocated} $member $clazz ${member.isIncompleteIn(clazz)}" )
123
+ }
124
+ else if (mix.name.isEmpty && ! (sym.owner is Trait ))
122
125
// SI-4989 Check if an intermediate class between `clazz` and `sym.owner` redeclares the method as abstract.
123
- for (intermediateClass <- clazz.info.baseClasses.tail.takeWhile(_ != sym.owner)) {
124
- val overriding = sym.overridingSymbol(intermediateClass)
125
- if ((overriding is (Deferred , butNot = AbsOverride )) && ! (overriding.owner is Trait ))
126
- ctx.error(
126
+ for (intermediateClass <- clazz.info.baseClasses.tail.takeWhile(_ != sym.owner)) {
127
+ val overriding = sym.overridingSymbol(intermediateClass)
128
+ if ((overriding is(Deferred , butNot = AbsOverride )) && ! (overriding.owner is Trait ))
129
+ ctx.error(
127
130
s " ${sym.showLocated} cannot be directly accessed from ${clazz} because ${overriding.owner} redeclares it as abstract " ,
128
131
sel.pos)
129
132
130
- }
131
- if (name.isTermName && mix.name.isEmpty &&
132
- ((clazz is Trait ) || clazz != ctx.owner.enclosingClass || ! validCurrentClass))
133
- superAccessorCall(sel)(ctx.withPhase(thisTransformer.next))
134
- else sel
133
+ }
134
+
135
+ if (name.isTermName && mix.name.isEmpty &&
136
+ ((clazz is Trait ) || clazz != ctx.owner.enclosingClass || ! validCurrentClass))
137
+ superAccessorCall(sel)(ctx.withPhase(thisTransformer.next))
138
+ else sel
139
+ }
135
140
}
136
141
137
142
/** Disallow some super.XX calls targeting Any methods which would
0 commit comments