Skip to content

Commit c6c5389

Browse files
committed
Fix tuples inlining
When inlining a `this` binding that referes to a result typed with a match type, this type must be normalized and used.
1 parent 927ae4e commit c6c5389

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
301301
private def registerType(tpe: Type): Unit = tpe match {
302302
case tpe: ThisType if !canElideThis(tpe) && !thisProxy.contains(tpe.cls) =>
303303
val proxyName = s"${tpe.cls.name}_this".toTermName
304-
val proxyType = tpe.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner).widenIfUnstable
304+
val proxyType = inlineCallPrefix.tpe.tryNormalize match {
305+
case typeMatchResult if typeMatchResult.exists => typeMatchResult
306+
case _ => tpe.asSeenFrom(inlineCallPrefix.tpe, inlinedMethod.owner).widenIfUnstable
307+
}
305308
thisProxy(tpe.cls) = newSym(proxyName, InlineProxy, proxyType).termRef
306309
if (!tpe.cls.isStaticOwner)
307310
registerType(inlinedMethod.owner.thisType) // make sure we have a base from which to outer-select
File renamed without changes.

tests/run/tuples1a.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test extends App {
2+
val t7 = '5' *: 4 *: "C" *: ()
3+
4+
val t7a = t7.tail
5+
val t7b = t7a.tail
6+
val t7c: Unit = (t7.tail: (Int, String)).tail
7+
val t7d: Unit = (t7.tail: Int *: String *: Unit).tail
8+
val t7e: Unit = t7.tail.tail
9+
}

0 commit comments

Comments
 (0)