Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #18816: Transfer the span of rewired This nodes in fullyParameterizedDef. #18840

Merged
merged 1 commit into from
Nov 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ trait FullParameterization {
.subst(origLeadingTypeParamSyms ++ origOtherParamSyms, (trefs ++ argRefs).tpes)
.substThisUnlessStatic(origClass, thisRef.tpe),
treeMap = {
case tree: This if tree.symbol == origClass => thisRef
case tree: This if tree.symbol == origClass => thisRef.withSpan(tree.span)
case tree => rewireTree(tree, Nil) orElse tree
},
oldOwners = origMeth :: Nil,
Expand Down
32 changes: 32 additions & 0 deletions compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,38 @@ class DottyBytecodeTests extends DottyBytecodeTest {

}
}

@Test def i18816 = {
// The primary goal of this test is to check that `LineNumber` have correct numbers
val source =
"""trait Context
|
|class A(x: Context) extends AnyVal:
| given [T]: Context = x
|
| def m1 =
| println(m3)
| def m2 =
| m3 // line 9
| println(m2)
|
| def m3(using Context): String = ""
""".stripMargin

checkBCode(source) { dir =>
val clsIn = dir.lookupName("A$.class", directory = false).input
val clsNode = loadClassNode(clsIn, skipDebugInfo = false)
val method = getMethod(clsNode, "m2$1")
val instructions = instructionsFromMethod(method).filter(_.isInstanceOf[LineNumber])

// There used to be references to line 7 here
val expected = List(
LineNumber(9, Label(0)),
)

assertSameCode(instructions, expected)
}
}
}

object invocationReceiversTestCode {
Expand Down
Loading