Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
// constructor method should not be semi-erased.
else if (isConstructor && isDerivedValueClass(sym)) eraseNormalClassRef(tp)
else this(tp)
case AppliedType(tycon, _) if !erasureDependsOnArgs(tycon) =>
case AppliedType(tycon, _) if tycon.typeSymbol.isClass && !erasureDependsOnArgs(tycon) =>
eraseResult(tycon)
case _ =>
this(tp)
Expand Down
25 changes: 25 additions & 0 deletions compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,29 @@ class TestBCode extends DottyBytecodeTest {
}
}

/** Test that type lambda applications are properly dealias */
@Test def i5090 = {
val source =
"""class Test {
| type T[X] = X
|
| def test(i: T[Int]): T[Int] = i
| def ref(i: Int): Int = i
|}
""".stripMargin

checkBCode(source) { dir =>
val clsIn = dir.lookupName("Test.class", directory = false).input
val clsNode = loadClassNode(clsIn)
val test = getMethod(clsNode, "test")
val ref = getMethod(clsNode, "ref")

val testInstructions = instructionsFromMethod(test)
val refInstructions = instructionsFromMethod(ref)

assert(testInstructions == refInstructions,
"`T[Int]` was not properly dealias" +
diffInstructions(testInstructions, refInstructions))
}
}
}
4 changes: 4 additions & 0 deletions tests/pos/i5090.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class TypeAlias {
type T[X] = X
def a(i: T[Int]): T[Int] = i
}