From 319d2c6887bea9e7b2beafd9fcb9bf5e52addac7 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 1 May 2024 18:11:38 +0200 Subject: [PATCH] Fix outerSelect in Inliner Fixes #20300 [Cherry-picked ae82716a207e07443392ff37392b9c3213ddbbce] --- compiler/src/dotty/tools/dotc/inlines/Inliner.scala | 2 +- tests/pos/i20300.scala | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i20300.scala diff --git a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala index d2817a879a04..0e5f51daafdb 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inliner.scala @@ -315,7 +315,7 @@ class Inliner(val call: tpd.Tree)(using Context): case Super(qual, _) => qual case pre => pre val preLevel = classNestingLevel(inlinedMethod.owner) - if preLevel > level then outerSelect(pre, inlinedMethod.owner, preLevel - level, selfSym.info) + if preLevel > level then outerSelect(pre, inlinedMethod.owner.enclosingClass, preLevel - level, selfSym.info) else pre val binding = accountForOpaques( diff --git a/tests/pos/i20300.scala b/tests/pos/i20300.scala new file mode 100644 index 000000000000..721b79940ba1 --- /dev/null +++ b/tests/pos/i20300.scala @@ -0,0 +1,8 @@ +trait T: + + def v() = () + + trait F: + def f(): Unit = + inline def op(): Unit = v() + op() \ No newline at end of file