@@ -14,7 +14,6 @@ import config.Printers.init as printer
1414import reporting .trace as log
1515
1616import Errors ._
17- import Util ._
1817
1918import scala .collection .mutable
2019
@@ -212,8 +211,7 @@ class Semantic {
212211 case thisRef : ThisRef =>
213212 val target =
214213 if superType.exists then
215- // TODO: superType could be A & B when there is self-annotation
216- resolveSuper(thisRef.klass, superType.classSymbol.asClass, meth)
214+ resolveSuper(thisRef.klass, superType, meth)
217215 else
218216 resolve(thisRef.klass, meth)
219217 if target.isOneOf(Flags .Method | Flags .Lazy ) then
@@ -239,8 +237,7 @@ class Semantic {
239237 case warm : Warm =>
240238 val target =
241239 if superType.exists then
242- // TODO: superType could be A & B when there is self-annotation
243- resolveSuper(warm.klass, superType.classSymbol.asClass, meth)
240+ resolveSuper(warm.klass, superType, meth)
244241 else
245242 resolve(warm.klass, meth)
246243 if target.is(Flags .Param ) then
@@ -706,7 +703,7 @@ class Semantic {
706703 // init param fields
707704 klass.paramAccessors.foreach { acc =>
708705 if (! acc.is(Flags .Method )) {
709- traceIndented (acc.show + " initialized" , printer )
706+ printer.println (acc.show + " initialized" )
710707 thisV.updateField(acc, Hot )
711708 }
712709 }
@@ -843,4 +840,25 @@ object Semantic {
843840 Some ((tref, newTree, fn.symbol, argss))
844841 case _ => None
845842 }
843+
844+ extension (symbol : Symbol ) def hasSource (using Context ): Boolean =
845+ ! symbol.defTree.isEmpty
846+
847+ def resolve (cls : ClassSymbol , sym : Symbol )(using Context ): Symbol =
848+ if (sym.isEffectivelyFinal || sym.isConstructor) sym
849+ else sym.matchingMember(cls.appliedRef)
850+
851+ def resolveSuper (cls : ClassSymbol , superType : Type , sym : Symbol )(using Context ): Symbol = {
852+ import annotation .tailrec
853+ @ tailrec def loop (bcs : List [ClassSymbol ]): Symbol = bcs match {
854+ case bc :: bcs1 =>
855+ val cand = sym.matchingDecl(bcs.head, cls.thisType)
856+ .suchThat(alt => ! alt.is(Flags .Deferred )).symbol
857+ if (cand.exists) cand else loop(bcs.tail)
858+ case _ =>
859+ NoSymbol
860+ }
861+ loop(cls.info.baseClasses.dropWhile(sym.owner != _))
862+ }
863+
846864}
0 commit comments