File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ object Checking {
278
278
val target = resolveSuper(cls, supercls, sym)
279
279
if (! target.is(Flags .Method ))
280
280
check(FieldAccess (pot, target)(eff.source))
281
- if (target.isInternal) {
281
+ else if (target.isInternal) {
282
282
val effs = thisRef.effectsOf(target)
283
283
effs.foreach { check(_) }
284
284
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Contexts.Context
7
7
import Symbols ._
8
8
import config .Printers .Printer
9
9
10
+ import annotation .tailrec
10
11
11
12
object Util {
12
13
def traceIndented (msg : String , printer : Printer )(implicit ctx : Context ): Unit =
@@ -25,6 +26,16 @@ object Util {
25
26
if (sym.isEffectivelyFinal || sym.isConstructor) sym
26
27
else sym.matchingMember(cls.typeRef)
27
28
28
- def resolveSuper (cls : ClassSymbol , superCls : ClassSymbol , sym : Symbol )(implicit ctx : Context ): Symbol =
29
- sym.superSymbolIn(cls)
29
+ def resolveSuper (cls : ClassSymbol , superCls : ClassSymbol , sym : Symbol )(implicit ctx : Context ): Symbol = {
30
+ // println(s"bases of $cls: " + cls.info.baseClasses)
31
+ @ tailrec def loop (bcs : List [ClassSymbol ]): Symbol = bcs match {
32
+ case bc :: bcs1 =>
33
+ val cand = sym.matchingDecl(bcs.head, cls.thisType)
34
+ .suchThat(alt => ! alt.is(Flags .Deferred )).symbol
35
+ if (cand.exists) cand else loop(bcs.tail)
36
+ case _ =>
37
+ NoSymbol
38
+ }
39
+ loop(cls.info.baseClasses.dropWhile(sym.owner != _))
40
+ }
30
41
}
Original file line number Diff line number Diff line change
1
+ import scala .collection .mutable
2
+
3
+ class Foo {
4
+ private val map : mutable.Map [Int , String ] = mutable.Map .empty
5
+
6
+ def enter (k : Int , v : String ) = map(k) = v
7
+ }
8
+
9
+ class Bar extends Foo {
10
+ override def enter (k : Int , v : String ) = ???
11
+ def enterSuper (k : Int , v : String ) = super .enter(k, v)
12
+
13
+ enter(1 , " one" )
14
+ enterSuper(1 , " one" )
15
+ super .enter(2 , " two" )
16
+ }
You can’t perform that action at this time.
0 commit comments