@@ -270,12 +270,15 @@ class Inliner(val call: tpd.Tree)(using Context):
270270 assert(argss.isEmpty)
271271 true
272272
273+ /** The number of enclosing classes of this class, plus one */
274+ private def classNestingLevel (cls : Symbol ) = cls.ownersIterator.count(_.isClass)
275+
273276 // Compute val-definitions for all this-proxies and append them to `bindingsBuf`
274277 private def computeThisBindings () = {
275278 // All needed this-proxies, paired-with and sorted-by nesting depth of
276279 // the classes they represent (innermost first)
277280 val sortedProxies = thisProxy.toList
278- .map((cls, proxy) => (cls.ownersIterator.length , proxy.symbol, cls))
281+ .map((cls, proxy) => (classNestingLevel( cls) , proxy.symbol, cls))
279282 .sortBy(- _._1)
280283
281284 def outerSelect (prefix : Tree , prefixCls : Symbol , hops : Int , info : Type ) =
@@ -303,7 +306,7 @@ class Inliner(val call: tpd.Tree)(using Context):
303306 val pre = inlineCallPrefix match
304307 case Super (qual, _) => qual
305308 case pre => pre
306- val preLevel = inlinedMethod.owner.ownersIterator.length
309+ val preLevel = classNestingLevel( inlinedMethod.owner)
307310 if preLevel > level then outerSelect(pre, inlinedMethod.owner, preLevel - level, selfSym.info)
308311 else pre
309312
0 commit comments