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

No Semanticdb generated for lifted args #19970

Closed
rochala opened this issue Mar 18, 2024 · 1 comment · Fixed by #21856
Closed

No Semanticdb generated for lifted args #19970

rochala opened this issue Mar 18, 2024 · 1 comment · Fixed by #21856
Assignees
Milestone

Comments

@rochala
Copy link
Contributor

rochala commented Mar 18, 2024

Compiler version

3.4.0

Minimized code

Semanticdb does not include occurences in lifted args.
It can affect also other scenarios, but this one is a nice minimisation.

object T:
  def enrichedCompilerCompletions() =
    val compilerCompletions: Seq[String] = ???

    compilerCompletions
      .toList
      .filterInteresting()

  extension (l: List[String])
    def filterInteresting(qualType: String = ""): List[String] = ???

Output

[[syntax trees at end of                     typer]] 
package <empty>#106 {
  final lazy module val T: T#123 = new T#123#124#125()#126#127
  final module class T() extends Object#181#186#187()#188 {
    this: T#128.type#129 =>
    def enrichedCompilerCompletions(): List[String]#386 =
      {
        val compilerCompletions: Seq#37[String#42]#44 = ???#48#51
        {
          val l$1: List[String]#350 = compilerCompletions#52.toList#54#352
          T.filterInteresting#344(l$1#353)#355(
            this#357.filterInteresting$default$2#358(l$1#353)#359)#367
        }#368
      }#370
    #388
    extension (l: List#64[String#69]#71#76) def filterInteresting(
      qualType: String#79#150): List#87[String#92]#94 = ???#98#152
    def filterInteresting$default$2(l: List#64[String#69]#71#360):
      String @uncheckedVariance#365 = ""#83#389
  }#393
}#394

With semanticdb:

Test.scala
----------

Summary:
Schema => SemanticDB v4
Uri => Test.scala
Text => empty
Language => Scala
Symbols => 9 entries
Occurrences => 17 entries

Symbols:
_empty_/T. => final object T extends Object { self: T.type => +4 decls }
_empty_/T.enrichedCompilerCompletions(). => method enrichedCompilerCompletions(): List[String]
_empty_/T.filterInteresting$default$2(). => method filterInteresting$default$2(l: List[String]): String @uncheckedVariance
_empty_/T.filterInteresting$default$2().(l) => param l: List[String]
_empty_/T.filterInteresting(). => method filterInteresting(l: List[String])(qualType: String): List[String]
_empty_/T.filterInteresting().(l) => param l: List[String]
_empty_/T.filterInteresting().(qualType) => param qualType: String
local0 => val local compilerCompletions: Seq[String]
local1 => val local l$1: List[String]

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.`???`().
[9:7..9:24) => _empty_/T.filterInteresting().
[11:13..11:14) <= _empty_/T.filterInteresting$default$2().(l)
[11:13..11:14) <= _empty_/T.filterInteresting().(l)
[11:16..11:20) => scala/package.List#
[11:21..11:27) => scala/Predef.String#
[12:8..12:25) <= _empty_/T.filterInteresting().
[12:26..12:34) <= _empty_/T.filterInteresting().(qualType)
[12:36..12:42) => scala/Predef.String#
[12:50..12:54) => scala/package.List#
[12:55..12:61) => scala/Predef.String#
[12:65..12:68) => scala/Predef.`???`().

Expectation

Semanticdb should properly find occurences for val l$1: List[String]#350 = compilerCompletions#52.toList#54#352 after lifting.

@rochala
Copy link
Contributor Author

rochala commented Jul 1, 2024

I made a mistake when I reported this issue. I should have pointed out the more precise issue:

//> using scala 3.5.0-RC1-bin-SNAPSHOT
//> using option -Xprint:typer

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] = ???

Actual issue is present for toCompletionValues, which occurrence is not logged.
The current semanticdb output is:


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.`???`().
// MISSING CASE HERE [9:16..9:33) => _empty_/T.toCompletionValues().
[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.`???`().

The real problem is connected to the reported one, and is caused by lifting done in extension method application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment