@@ -270,12 +270,15 @@ class Inliner(val call: tpd.Tree)(using Context):
270
270
assert(argss.isEmpty)
271
271
true
272
272
273
+ /** The number of enclosing classes of this class, plus one */
274
+ private def classNestingLevel (cls : Symbol ) = cls.ownersIterator.count(_.isClass)
275
+
273
276
// Compute val-definitions for all this-proxies and append them to `bindingsBuf`
274
277
private def computeThisBindings () = {
275
278
// All needed this-proxies, paired-with and sorted-by nesting depth of
276
279
// the classes they represent (innermost first)
277
280
val sortedProxies = thisProxy.toList
278
- .map((cls, proxy) => (cls.ownersIterator.length , proxy.symbol, cls))
281
+ .map((cls, proxy) => (classNestingLevel( cls) , proxy.symbol, cls))
279
282
.sortBy(- _._1)
280
283
281
284
def outerSelect (prefix : Tree , prefixCls : Symbol , hops : Int , info : Type ) =
@@ -303,7 +306,7 @@ class Inliner(val call: tpd.Tree)(using Context):
303
306
val pre = inlineCallPrefix match
304
307
case Super (qual, _) => qual
305
308
case pre => pre
306
- val preLevel = inlinedMethod.owner.ownersIterator.length
309
+ val preLevel = classNestingLevel( inlinedMethod.owner)
307
310
if preLevel > level then outerSelect(pre, inlinedMethod.owner, preLevel - level, selfSym.info)
308
311
else pre
309
312
0 commit comments