@@ -14,7 +14,6 @@ import config.Printers.init as printer
14
14
import reporting .trace as log
15
15
16
16
import Errors ._
17
- import Util ._
18
17
19
18
import scala .collection .mutable
20
19
@@ -212,8 +211,7 @@ class Semantic {
212
211
case thisRef : ThisRef =>
213
212
val target =
214
213
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)
217
215
else
218
216
resolve(thisRef.klass, meth)
219
217
if target.isOneOf(Flags .Method | Flags .Lazy ) then
@@ -239,8 +237,7 @@ class Semantic {
239
237
case warm : Warm =>
240
238
val target =
241
239
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)
244
241
else
245
242
resolve(warm.klass, meth)
246
243
if target.is(Flags .Param ) then
@@ -706,7 +703,7 @@ class Semantic {
706
703
// init param fields
707
704
klass.paramAccessors.foreach { acc =>
708
705
if (! acc.is(Flags .Method )) {
709
- traceIndented (acc.show + " initialized" , printer )
706
+ printer.println (acc.show + " initialized" )
710
707
thisV.updateField(acc, Hot )
711
708
}
712
709
}
@@ -843,4 +840,25 @@ object Semantic {
843
840
Some ((tref, newTree, fn.symbol, argss))
844
841
case _ => None
845
842
}
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
+
846
864
}
0 commit comments