Skip to content

Commit 835bb84

Browse files
Merge pull request #9800 from dotty-staging/fix-missing-widening-of-inline-param-termrefs
Fix #9457 and #9626: Remove TermRef to inline parameters
2 parents 5c422e2 + 85e01c5 commit 835bb84

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
673673
def apply(t: Type) = t match {
674674
case t: ThisType => thisProxy.getOrElse(t.cls, t)
675675
case t: TypeRef => paramProxy.getOrElse(t, mapOver(t))
676-
case t: SingletonType => paramProxy.getOrElse(t, mapOver(t))
676+
case t: SingletonType =>
677+
if t.termSymbol.isAllOf(Inline | Param) then mapOver(t.widenTermRefExpr)
678+
else paramProxy.getOrElse(t, mapOver(t))
677679
case t => mapOver(t)
678680
}
679681
override def mapClassInfo(tp: ClassInfo) = mapFullClassInfo(tp)

tests/pos/i9457.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object inlinetuple:
2+
def test: Int =
3+
f((1, 2))
4+
inline def f(inline p: (Int, Int)): Int =
5+
val (a, b) = p
6+
a + b

tests/pos/i9626.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
inline def scaffolding(inline op: Unit): Unit =
2+
val _ = op
3+
4+
def test = scaffolding { println("foo") }

0 commit comments

Comments
 (0)