From 85e01c56b0db570dabe2e88d19235ac936f33481 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 15 Sep 2020 15:37:39 +0200 Subject: [PATCH] Fix #9457 and #9626: Remove TermRef to inline parameters For inline parameters we do not need to reeplace the parameter TermRef with the proxy TermRef as this one will immediately be removed. --- compiler/src/dotty/tools/dotc/typer/Inliner.scala | 4 +++- tests/pos/i9457.scala | 6 ++++++ tests/pos/i9626.scala | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i9457.scala create mode 100644 tests/pos/i9626.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 20396c08f631..7326d77262b2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -673,7 +673,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { def apply(t: Type) = t match { case t: ThisType => thisProxy.getOrElse(t.cls, t) case t: TypeRef => paramProxy.getOrElse(t, mapOver(t)) - case t: SingletonType => paramProxy.getOrElse(t, mapOver(t)) + case t: SingletonType => + if t.termSymbol.isAllOf(Inline | Param) then mapOver(t.widenTermRefExpr) + else paramProxy.getOrElse(t, mapOver(t)) case t => mapOver(t) } override def mapClassInfo(tp: ClassInfo) = mapFullClassInfo(tp) diff --git a/tests/pos/i9457.scala b/tests/pos/i9457.scala new file mode 100644 index 000000000000..c210e3dc92ff --- /dev/null +++ b/tests/pos/i9457.scala @@ -0,0 +1,6 @@ +object inlinetuple: + def test: Int = + f((1, 2)) + inline def f(inline p: (Int, Int)): Int = + val (a, b) = p + a + b diff --git a/tests/pos/i9626.scala b/tests/pos/i9626.scala new file mode 100644 index 000000000000..077122f58e33 --- /dev/null +++ b/tests/pos/i9626.scala @@ -0,0 +1,4 @@ +inline def scaffolding(inline op: Unit): Unit = + val _ = op + +def test = scaffolding { println("foo") }