@@ -1577,6 +1577,90 @@ class DottyBytecodeTests extends DottyBytecodeTest {
1577
1577
testSig(" bar" , " ()I" )
1578
1578
}
1579
1579
}
1580
+
1581
+ @ Test def i15535 = {
1582
+ // primary goal of this test is to check that `LineNumber` have correct numbers
1583
+ val source =
1584
+ """ object Main {
1585
+ | def m(x: Int): Unit = {
1586
+ | x match {
1587
+ | case y =>
1588
+ | println(y)
1589
+ | println(y)
1590
+ | }
1591
+ | }
1592
+ |}
1593
+ """ .stripMargin
1594
+
1595
+ checkBCode(source) { dir =>
1596
+ val clsIn = dir.lookupName(" Main$.class" , directory = false ).input
1597
+ val clsNode = loadClassNode(clsIn, skipDebugInfo = false )
1598
+ val method = getMethod(clsNode, " m" )
1599
+ val instructions = instructionsFromMethod(method).filter(_.isInstanceOf [LineNumber ])
1600
+
1601
+ val expected = List (
1602
+ LineNumber (2 , Label (0 )),
1603
+ LineNumber (3 , Label (0 )),
1604
+ LineNumber (4 , Label (5 )), // case y =>
1605
+ LineNumber (5 , Label (9 )),
1606
+ LineNumber (6 , Label (15 )),
1607
+ )
1608
+
1609
+ assertSameCode(instructions, expected)
1610
+ }
1611
+ }
1612
+
1613
+ @ Test def i15535_2 = {
1614
+ // primary goal of this test is to check that `LineNumber` have correct numbers
1615
+ val source =
1616
+ """ object Main {
1617
+ | def m(x: Matchable): Unit = {
1618
+ | x match {
1619
+ | case a if a == 3 =>
1620
+ | println(a)
1621
+ | println(a)
1622
+ | case b: Int =>
1623
+ | println(b)
1624
+ | println(b)
1625
+ | case c @ Left(l) =>
1626
+ | println(l)
1627
+ | println(c)
1628
+ | case d =>
1629
+ | println(d)
1630
+ | println(d)
1631
+ | println(d)
1632
+ | }
1633
+ | }
1634
+ |}
1635
+ """ .stripMargin
1636
+
1637
+ checkBCode(source) { dir =>
1638
+ val clsIn = dir.lookupName(" Main$.class" , directory = false ).input
1639
+ val clsNode = loadClassNode(clsIn, skipDebugInfo = false )
1640
+ val method = getMethod(clsNode, " m" )
1641
+ val instructions = instructionsFromMethod(method).filter(_.isInstanceOf [LineNumber ])
1642
+
1643
+ val expected = List (
1644
+ LineNumber (2 , Label (0 )),
1645
+ LineNumber (3 , Label (0 )),
1646
+ LineNumber (4 , Label (5 )), // case a if a == 3 =>
1647
+ LineNumber (5 , Label (15 )),
1648
+ LineNumber (6 , Label (20 )),
1649
+ LineNumber (7 , Label (26 )), // case b: Int =>
1650
+ LineNumber (8 , Label (35 )),
1651
+ LineNumber (9 , Label (41 )),
1652
+ LineNumber (10 , Label (48 )), // case c @ Left(l) =>
1653
+ LineNumber (11 , Label (63 )),
1654
+ LineNumber (12 , Label (68 )),
1655
+ LineNumber (13 , Label (74 )), // case d =>
1656
+ LineNumber (14 , Label (79 )),
1657
+ LineNumber (15 , Label (84 )),
1658
+ LineNumber (16 , Label (89 )),
1659
+ )
1660
+
1661
+ assertSameCode(instructions, expected)
1662
+ }
1663
+ }
1580
1664
}
1581
1665
1582
1666
object invocationReceiversTestCode {
0 commit comments