Skip to content

SemanticDB is not being generated for extension methods #18570

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

Closed
kpodsiad opened this issue Sep 19, 2023 · 4 comments
Closed

SemanticDB is not being generated for extension methods #18570

kpodsiad opened this issue Sep 19, 2023 · 4 comments

Comments

@kpodsiad
Copy link

Raised in scalameta/metals#5478, I've encountered this on my own as well when defining extension methods in companion object for trait.

Compiler version

3.3.1

Minimized code

//> using scala "3.3.1"

opaque type Deck = Long

object Deck {
  extension (data: Deck) {
    def fooSize: Int = ???
  }
}

// import Deck.* // uncomment and semanticDB will be properly generated
object DeckUsage {
  val deck: Deck = ???
  deck.fooSize
}

Output

Generated semanticDB file doesn't contain entries for fooSize usage in object DeckUsage

Expectation

Generated semanticDB file doesn't contain entries for fooSize usage in object DeckUsage, without need for an additional import

@kpodsiad kpodsiad added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 19, 2023
@Kordyjan Kordyjan added area:semanticdb and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 19, 2023
@Kordyjan
Copy link
Contributor

@tanishiking can you take a look?

@tgodzik
Copy link
Contributor

tgodzik commented Sep 19, 2023

There is the same issue in the presentation compiler, which seems unrelated. Could it due to those extension methods being resolved at a later phase?

@tanishiking
Copy link
Member

tanishiking commented Sep 19, 2023

It seems like caused by the missing span for extension method
https://github.com/lampepfl/dotty/blob/a37dac66b1d48e8ac173dd4b2486b353f8574cc2/compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala#L243 and it might be #18557 will help 👍 FYI @kasiaMarek

Confirmed it is fixed by #18557

@bishabosha
Copy link
Member

fixed by #18557

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

No branches or pull requests

5 participants