@@ -275,12 +275,18 @@ class Inliner(val call: tpd.Tree)(using Context):
275
275
// All needed this-proxies, paired-with and sorted-by nesting depth of
276
276
// the classes they represent (innermost first)
277
277
val sortedProxies = thisProxy.toList
278
- .map((cls, proxy) => (cls.ownersIterator.length, proxy.symbol))
278
+ .map((cls, proxy) => (cls.ownersIterator.length, proxy.symbol, cls ))
279
279
.sortBy(- _._1)
280
280
281
+ def outerSelect (prefix : Symbol , prefixCls : Symbol , level : Int , info : Type ) =
282
+ val tpt = TypeTree (adaptToPrefix(prefixCls.appliedRef))
283
+ val qual = Typed (ref(prefix), tpt)
284
+ qual.outerSelect(level, info)
285
+
281
286
var lastSelf : Symbol = NoSymbol
287
+ var lastCls : Symbol = NoSymbol
282
288
var lastLevel : Int = 0
283
- for ((level, selfSym) <- sortedProxies) {
289
+ for ((level, selfSym, cls ) <- sortedProxies) {
284
290
val rhs = selfSym.info.dealias match
285
291
case info : TermRef
286
292
if info.isStable && (lastSelf.exists || isPureExpr(inlineCallPrefix)) =>
@@ -292,7 +298,7 @@ class Inliner(val call: tpd.Tree)(using Context):
292
298
if rhsClsSym.is(Module ) && rhsClsSym.isStatic then
293
299
ref(rhsClsSym.sourceModule)
294
300
else if lastSelf.exists then
295
- ref(lastSelf). outerSelect(lastLevel - level, selfSym.info)
301
+ outerSelect(lastSelf, lastCls, lastLevel - level, selfSym.info)
296
302
else
297
303
val pre = inlineCallPrefix match
298
304
case Super (qual, _) => qual
@@ -307,6 +313,7 @@ class Inliner(val call: tpd.Tree)(using Context):
307
313
inlining.println(i " proxy at $level: $selfSym = ${bindingsBuf.last}" )
308
314
lastSelf = selfSym
309
315
lastLevel = level
316
+ lastCls = cls
310
317
}
311
318
}
312
319
@@ -417,6 +424,8 @@ class Inliner(val call: tpd.Tree)(using Context):
417
424
|| tpe.cls.is(Package )
418
425
|| tpe.cls.isStaticOwner && ! (tpe.cls.seesOpaques && inlinedMethod.isContainedIn(tpe.cls))
419
426
427
+ private def adaptToPrefix (tp : Type ) = tp.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner)
428
+
420
429
/** Populate `thisProxy` and `paramProxy` as follows:
421
430
*
422
431
* 1a. If given type refers to a static this, thisProxy binds it to corresponding global reference,
@@ -432,14 +441,11 @@ class Inliner(val call: tpd.Tree)(using Context):
432
441
private def registerType (tpe : Type ): Unit = tpe match {
433
442
case tpe : ThisType if ! canElideThis(tpe) && ! thisProxy.contains(tpe.cls) =>
434
443
val proxyName = s " ${tpe.cls.name}_this " .toTermName
435
- def adaptToPrefix (tp : Type ) = tp.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner)
436
444
val proxyType = inlineCallPrefix.tpe.dealias.tryNormalize match {
437
445
case typeMatchResult if typeMatchResult.exists => typeMatchResult
438
446
case _ => adaptToPrefix(tpe).widenIfUnstable
439
447
}
440
448
thisProxy(tpe.cls) = newSym(proxyName, InlineProxy , proxyType).termRef
441
- if (! tpe.cls.isStaticOwner)
442
- registerType(inlinedMethod.owner.thisType) // make sure we have a base from which to outer-select
443
449
for (param <- tpe.cls.typeParams)
444
450
paramProxy(param.typeRef) = adaptToPrefix(param.typeRef)
445
451
case tpe : NamedType
0 commit comments