@@ -779,8 +779,8 @@ object Semantic:
779
779
if tryReporter.errors.nonEmpty && isSyntheticApply(meth) then
780
780
tryReporter.abort()
781
781
val klass = meth.owner.companionClass.asClass
782
- val outerCls = klass.owner.lexicallyEnclosingClass.asClass
783
- val outer = resolveOuterSelect(outerCls , ref, 1 )
782
+ val targetCls = klass.owner.lexicallyEnclosingClass.asClass
783
+ val outer = resolveThis(targetCls , ref, meth.owner.asClass )
784
784
outer.instantiate(klass, klass.primaryConstructor, args)
785
785
else
786
786
reporter.reportAll(tryReporter.errors)
@@ -1322,9 +1322,12 @@ object Semantic:
1322
1322
val qual = eval(qualifier, thisV, klass)
1323
1323
1324
1324
name match
1325
- case OuterSelectName (_, hops) =>
1326
- val SkolemType (tp) = expr.tpe: @ unchecked
1327
- withTrace(trace2) { resolveOuterSelect(tp.classSymbol.asClass, qual, hops) }
1325
+ case OuterSelectName (_, _) =>
1326
+ val current = qualifier.tpe.classSymbol
1327
+ val target = expr.tpe.widenSingleton.classSymbol.asClass
1328
+ withTrace(trace2) {
1329
+ resolveThis(target, qual, current.asClass)
1330
+ }
1328
1331
case _ =>
1329
1332
withTrace(trace2) { qual.select(expr.symbol) }
1330
1333
@@ -1493,41 +1496,6 @@ object Semantic:
1493
1496
1494
1497
}
1495
1498
1496
- /** Resolve outer select introduced during inlining.
1497
- *
1498
- * See `tpd.outerSelect` and `ElimOuterSelect`.
1499
- */
1500
- def resolveOuterSelect (target : ClassSymbol , thisV : Value , hops : Int ): Contextual [Value ] = log(" resolving outer " + target.show + " , this = " + thisV.show + " , hops = " + hops, printer, (_ : Value ).show) {
1501
- // Is `target` reachable from `cls` with the given `hops`?
1502
- def reachable (cls : ClassSymbol , hops : Int ): Boolean = log(" reachable from " + cls + " -> " + target + " in " + hops, printer) {
1503
- if hops == 0 then cls == target
1504
- else reachable(cls.owner.lexicallyEnclosingClass.asClass, hops - 1 )
1505
- }
1506
-
1507
- thisV match
1508
- case Hot => Hot
1509
-
1510
- case ref : Ref =>
1511
- val obj = ref.objekt
1512
- val curOpt = obj.klass.baseClasses.find(cls => reachable(cls, hops))
1513
- curOpt match
1514
- case Some (cur) =>
1515
- resolveThis(target, thisV, cur)
1516
-
1517
- case None =>
1518
- report.error(" [Internal error] unexpected outerSelect, thisV = " + thisV + " , target = " + target.show + " , hops = " + hops, trace.toVector.last.srcPos)
1519
- Cold
1520
-
1521
- case RefSet (refs) =>
1522
- refs.map(ref => resolveOuterSelect(target, ref, hops)).join
1523
-
1524
- case fun : Fun =>
1525
- report.error(" [Internal error] unexpected thisV = " + thisV + " , target = " + target.show + " , hops = " + hops, trace.toVector.last.srcPos)
1526
- Cold
1527
-
1528
- case Cold => Cold
1529
- }
1530
-
1531
1499
/** Compute the outer value that correspond to `tref.prefix` */
1532
1500
def outerValue (tref : TypeRef , thisV : Ref , klass : ClassSymbol ): Contextual [Value ] =
1533
1501
val cls = tref.classSymbol.asClass
0 commit comments