-
Notifications
You must be signed in to change notification settings - Fork 1.1k
When registering Ident use, consider the original span for synthetics #20575
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
When registering Ident use, consider the original span for synthetics #20575
Conversation
I looked at this, and I think it didn't solve the issue I've had, but the reason is completely on me. I made a mistake when I reported it. Likewise, I have updated the comment on the issue with the real reproduction. The fix should be similar, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the solution has to be a bit different.
Right now we're logging the occurence of local1, but we should instead go to the RHS of the ValDef from lifting. Then we should go over all calls and register their usage (they have correct spans).
Example:
object T:
def enrichedCompilerCompletions() =
val compilerCompletions: Seq[String] = ???
compilerCompletions
.toList
.flatMap(toCompletionValues)
.filterInteresting()
def toCompletionValues(x: String): List[String] = ???
extension (l: List[String])
def filterInteresting(qualType: String = ""): List[String] = ???
results in:
Occurrences:
[3:7..3:8) <= _empty_/T.
[4:6..4:33) <= _empty_/T.enrichedCompilerCompletions().
[5:8..5:27) <= local0
[5:29..5:32) => scala/package.Seq#
[5:33..5:39) => scala/Predef.String#
[5:43..5:46) => scala/Predef.`???`().
[7:4..9:34) => local1
[10:7..10:24) => _empty_/T.filterInteresting().
[13:6..13:24) <= _empty_/T.toCompletionValues().
[13:25..13:26) <= _empty_/T.toCompletionValues().(x)
[13:28..13:34) => scala/Predef.String#
[13:37..13:41) => scala/package.List#
[13:42..13:48) => scala/Predef.String#
[13:52..13:55) => scala/Predef.`???`().
[15:13..15:14) <= _empty_/T.filterInteresting$default$2().(l)
[15:13..15:14) <= _empty_/T.filterInteresting().(l)
[15:16..15:20) => scala/package.List#
[15:21..15:27) => scala/Predef.String#
[16:8..16:25) <= _empty_/T.filterInteresting().
[16:26..16:34) <= _empty_/T.filterInteresting().(qualType)
[16:36..16:42) => scala/Predef.String#
[16:50..16:54) => scala/package.List#
[16:55..16:61) => scala/Predef.String#
[16:65..16:68) => scala/Predef.`???`().
But it should rather be:
Occurrences:
[3:7..3:8) <= _empty_/T.
[4:6..4:33) <= _empty_/T.enrichedCompilerCompletions().
[5:8..5:27) <= local0
[5:29..5:32) => scala/package.Seq#
[5:33..5:39) => scala/Predef.String#
[5:43..5:46) => scala/Predef.`???`().
[7:4..7:22) => local0
[8:6..8:12] => .toList
[9:6..9:xx] => .flatMap
[9:xx..9:yy] => toCompletionValue
[10:7..10:24) => _empty_/T.filterInteresting().
[13:6..13:24) <= _empty_/T.toCompletionValues().
[13:25..13:26) <= _empty_/T.toCompletionValues().(x)
[13:28..13:34) => scala/Predef.String#
[13:37..13:41) => scala/package.List#
[13:42..13:48) => scala/Predef.String#
[13:52..13:55) => scala/Predef.`???`().
[15:13..15:14) <= _empty_/T.filterInteresting$default$2().(l)
[15:13..15:14) <= _empty_/T.filterInteresting().(l)
[15:16..15:20) => scala/package.List#
[15:21..15:27) => scala/Predef.String#
[16:8..16:25) <= _empty_/T.filterInteresting().
[16:26..16:34) <= _empty_/T.filterInteresting().(qualType)
[16:36..16:42) => scala/Predef.String#
[16:50..16:54) => scala/package.List#
[16:55..16:61) => scala/Predef.String#
[16:65..16:68) => scala/Predef.`???`().
@@ -4,7 +4,7 @@ object NamedApplyBlockMethods/*<-example::NamedApplyBlockMethods.*/ { | |||
val local/*<-example::NamedApplyBlockMethods.local.*/ = 1 | |||
def foo/*<-example::NamedApplyBlockMethods.foo().*/(a/*<-example::NamedApplyBlockMethods.foo().(a)*/: Int/*->scala::Int#*/ = 1, b/*<-example::NamedApplyBlockMethods.foo().(b)*/: Int/*->scala::Int#*/ = 2, c/*<-example::NamedApplyBlockMethods.foo().(c)*/: Int/*->scala::Int#*/ = 3): Int/*->scala::Int#*/ = a/*->example::NamedApplyBlockMethods.foo().(a)*/ +/*->scala::Int#`+`(+4).*/ b/*->example::NamedApplyBlockMethods.foo().(b)*/ +/*->scala::Int#`+`(+4).*/ c/*->example::NamedApplyBlockMethods.foo().(c)*/ | |||
def baseCase/*<-example::NamedApplyBlockMethods.baseCase().*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = 3) | |||
def recursive/*<-example::NamedApplyBlockMethods.recursive().*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = 3)) | |||
def recursive/*<-example::NamedApplyBlockMethods.recursive().*/ = foo/*->example::NamedApplyBlockMethods.foo().*//*->local1*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def recursive/*<-example::NamedApplyBlockMethods.recursive().*/ = foo/*->example::NamedApplyBlockMethods.foo().*//*->local1*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = 3)) | |
def recursive/*<-example::NamedApplyBlockMethods.recursive().*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = foo/*->example::NamedApplyBlockMethods.foo().*/(local/*->example::NamedApplyBlockMethods.local.*/, c/*->example::NamedApplyBlockMethods.foo().(c)*/ = 3)) |
That local doesn't exist in the source code so we should not add it to occurrences
Superceded by #21856 |
Fix #19970
Apply | TypeApply
tree