diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 4fede9b6b9e4..196b678f0685 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -1548,13 +1548,14 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { //if the projection leads to a typed tree then we stop reduction resNoReduce else - val resMaybeReduced = constToLiteral(reducedProjection) - if resNoReduce ne resMaybeReduced then - typed(resMaybeReduced, pt) // redo typecheck if reduction changed something + val res = constToLiteral(reducedProjection) + if resNoReduce ne res then + typed(res, pt) // redo typecheck if reduction changed something + else if res.symbol.isInlineMethod then + inlineIfNeeded(res) else - val res = resMaybeReduced ensureAccessible(res.tpe, tree.qualifier.isInstanceOf[untpd.Super], tree.srcPos) - inlineIfNeeded(res) + res } override def typedIf(tree: untpd.If, pt: Type)(using Context): Tree = diff --git a/tests/pos/i14048.scala b/tests/pos/i14048.scala new file mode 100644 index 000000000000..b815b68c72fd --- /dev/null +++ b/tests/pos/i14048.scala @@ -0,0 +1,5 @@ +class T: + inline def foo(): Unit = bar() + private inline def bar(): Unit = () + +def test(t: T) = t.foo()