@@ -1785,6 +1785,64 @@ class DottyBytecodeTests extends DottyBytecodeTest {
17851785    }
17861786  }
17871787
1788+ 
1789+   @ Test  def  i15098  =  {
1790+     val  source  = 
1791+       """ object Main {
1792+         |  def main(args: Array[String]): Unit = { 
1793+         |    Array(1).foreach { n => 
1794+         |      val x = 123 
1795+         |      println(n) 
1796+         |    } 
1797+         |  } 
1798+         |} 
1799+         """  .stripMargin
1800+ 
1801+     checkBCode(source) { dir => 
1802+       val  clsIn    =  dir.lookupName(" Main$.class" =  false ).input
1803+       val  clsNode  =  loadClassNode(clsIn, skipDebugInfo =  false )
1804+       val  method   =  getMethod(clsNode, " main" 
1805+       val  instructions  =  instructionsFromMethod(method).filter(_.isInstanceOf [LineNumber ])
1806+ 
1807+       val  expected  =  List (
1808+         LineNumber (3 , Label (0 )),
1809+       )
1810+ 
1811+       assertSameCode(instructions, expected)
1812+     }
1813+   }
1814+ 
1815+   @ Test  def  i15098_2  =  {
1816+     val  source  = 
1817+       """ object Main {
1818+         |  def main(args: Array[String]): Unit = { 
1819+         |    Array(1).map { n => 
1820+         |      val x = 123 
1821+         |      x + n 
1822+         |    }.foreach { n => 
1823+         |      println(n) 
1824+         |      println(n) 
1825+         |    } 
1826+         |  } 
1827+         |} 
1828+         """  .stripMargin
1829+ 
1830+     checkBCode(source) { dir => 
1831+       val  clsIn    =  dir.lookupName(" Main$.class" =  false ).input
1832+       val  clsNode  =  loadClassNode(clsIn, skipDebugInfo =  false )
1833+       val  method   =  getMethod(clsNode, " main" 
1834+       val  instructions  =  instructionsFromMethod(method).filter(_.isInstanceOf [LineNumber ])
1835+ 
1836+       val  expected  =  List (
1837+         LineNumber (3 , Label (0 )),
1838+         LineNumber (6 , Label (15 )),
1839+         LineNumber (3 , Label (24 )),
1840+         LineNumber (6 , Label (27 )),
1841+       )
1842+ 
1843+       assertSameCode(instructions, expected)
1844+     }
1845+   }
17881846}
17891847
17901848object  invocationReceiversTestCode  {
0 commit comments