Skip to content

Commit 98396ad

Browse files
committed
Add byte code test:
Test that T[Int] erases to Int where type T[X] = X
1 parent 8bb3f06 commit 98396ad

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,29 @@ class TestBCode extends DottyBytecodeTest {
450450
}
451451
}
452452

453+
/** Test that type lambda applications are properly dealias */
454+
@Test def i5090 = {
455+
val source =
456+
"""class Test {
457+
| type T[X] = X
458+
|
459+
| def test(i: T[Int]): T[Int] = i
460+
| def ref(i: Int): Int = i
461+
|}
462+
""".stripMargin
463+
464+
checkBCode(source) { dir =>
465+
val clsIn = dir.lookupName("Test.class", directory = false).input
466+
val clsNode = loadClassNode(clsIn)
467+
val test = getMethod(clsNode, "test")
468+
val ref = getMethod(clsNode, "ref")
469+
470+
val testInstructions = instructionsFromMethod(test)
471+
val refInstructions = instructionsFromMethod(ref)
472+
473+
assert(testInstructions == refInstructions,
474+
"`T[Int]` was not properly dealias" +
475+
diffInstructions(testInstructions, refInstructions))
476+
}
477+
}
453478
}

tests/pos/i5090.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class TypeAlias {
22
type T[X] = X
33
def a(i: T[Int]): T[Int] = i
4-
}
4+
}

0 commit comments

Comments
 (0)