File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
src/dotty/tools/dotc/transform
test/dotty/tools/backend/jvm Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ trait FullParameterization {
207207 .subst(origLeadingTypeParamSyms ++ origOtherParamSyms, (trefs ++ argRefs).tpes)
208208 .substThisUnlessStatic(origClass, thisRef.tpe),
209209 treeMap = {
210- case tree : This if tree.symbol == origClass => thisRef
210+ case tree : This if tree.symbol == origClass => thisRef.withSpan(tree.span)
211211 case tree => rewireTree(tree, Nil ) orElse tree
212212 },
213213 oldOwners = origMeth :: Nil ,
Original file line number Diff line number Diff line change @@ -1701,6 +1701,38 @@ class DottyBytecodeTests extends DottyBytecodeTest {
17011701
17021702 }
17031703 }
1704+
1705+ @ Test def i18816 = {
1706+ // The primary goal of this test is to check that `LineNumber` have correct numbers
1707+ val source =
1708+ """ trait Context
1709+ |
1710+ |class A(x: Context) extends AnyVal:
1711+ | given [T]: Context = x
1712+ |
1713+ | def m1 =
1714+ | println(m3)
1715+ | def m2 =
1716+ | m3 // line 9
1717+ | println(m2)
1718+ |
1719+ | def m3(using Context): String = ""
1720+ """ .stripMargin
1721+
1722+ checkBCode(source) { dir =>
1723+ val clsIn = dir.lookupName(" A$.class" , directory = false ).input
1724+ val clsNode = loadClassNode(clsIn, skipDebugInfo = false )
1725+ val method = getMethod(clsNode, " m2$1" )
1726+ val instructions = instructionsFromMethod(method).filter(_.isInstanceOf [LineNumber ])
1727+
1728+ // There used to be references to line 7 here
1729+ val expected = List (
1730+ LineNumber (9 , Label (0 )),
1731+ )
1732+
1733+ assertSameCode(instructions, expected)
1734+ }
1735+ }
17041736}
17051737
17061738object invocationReceiversTestCode {
You can’t perform that action at this time.
0 commit comments