Skip to content

[SemanticDB] ExtractSemanticDB doesn't emit symbol for anonymous class #15852

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
tanishiking opened this issue Aug 13, 2022 · 1 comment · Fixed by #15865
Closed

[SemanticDB] ExtractSemanticDB doesn't emit symbol for anonymous class #15852

tanishiking opened this issue Aug 13, 2022 · 1 comment · Fixed by #15865
Assignees
Milestone

Comments

@tanishiking
Copy link
Member

tanishiking commented Aug 13, 2022

Originally reported scalameta/metals#4246

Compiler version

3.1.3

Minimized code

package exampleNew

trait Foo {
  def foo: String
}

object Foo {
  lazy val make: Foo =
    new Foo {
      override lazy val foo: String = "foo"
    }
}

Output

package exampleNew

trait Foo/*<-exampleNew::Foo#*/ {
  def foo/*<-exampleNew::Foo#foo().*/: String/*->scala::Predef.String#*/
}

object Foo/*<-exampleNew::Foo.*/ {
  lazy val make/*<-exampleNew::Foo.make.*/: Foo/*->exampleNew::Foo#*/ =
    new Foo/*->exampleNew::Foo#*/ {
      override lazy val foo/*<-local0*/: String/*->scala::Predef.String#*/ = "foo"
    }
}

Expectation

package exampleNew

trait Foo/*<=exampleNew.Foo#*/ {
  def foo/*<=exampleNew.Foo#foo().*/: String/*=>scala.Predef.String#*/
}

object Foo/*<=exampleNew.Foo.*/ {
  lazy val make/*<=exampleNew.Foo.make.*/: Foo/*=>exampleNew.Foo#*/ =
    new /*<=local0*/Foo/*=>exampleNew.Foo#*/ /*=>java.lang.Object#`<init>`().*/{
      override lazy val foo/*<=local1*/: String/*=>scala.Predef.String#*/ = "foo"
    }
}
Symbols:
...
local0 => final class $anon extends AnyRef with Foo { +1 decls }
  AnyRef => scala/AnyRef#
  Foo => exampleNew/Foo#
local1 => lazy val method foo: String <: exampleNew/Foo#foo().
  String => scala/Predef.String#

@tanishiking tanishiking added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 13, 2022
@KacperFKorban KacperFKorban added area:semanticdb and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 13, 2022
@tanishiking
Copy link
Member Author

I'm working on it :)

tanishiking added a commit to tanishiking/scala3 that referenced this issue Aug 16, 2022
fix scala#15852

This commit enables ExtractSemanticDB to emit SymbolInformation and
SymbolOccurrence of anonymous classes.

e.g.

```scala
trait Foo:
  def foo: String

val foo1: Foo = new Foo { def foo: String = ??? }
val foo2: Foo = new { def foo: String = ??? }
```

While Scala2 semanticdb-plugin emit symbols for the anonymous class.

Lack of the symbol information / occurrence led Metals not being able to
find those anonymous classes as implementations by `go-to-implementation` from `trait Foo`.
bishabosha added a commit that referenced this issue Sep 13, 2022
… class (#15865)

fix #15852

This commit enables ExtractSemanticDB to emit SymbolInformation and
SymbolOccurrence of anonymous classes.

e.g.

```scala
trait Foo:
  def foo: String

val foo1: Foo = new Foo { def foo: String = ??? }
val foo2: Foo = new { def foo: String = ??? }
```

While Scala2 semanticdb-plugin emit symbols for the anonymous class.

Lack of the symbol information / occurrence led Metals not being able to
find those anonymous classes as implementations by
`go-to-implementation` from `trait Foo`.
see: scalameta/metals#4246
mpollmeier pushed a commit to mpollmeier/dotty that referenced this issue Oct 16, 2022
fix scala#15852

This commit enables ExtractSemanticDB to emit SymbolInformation and
SymbolOccurrence of anonymous classes.

e.g.

```scala
trait Foo:
  def foo: String

val foo1: Foo = new Foo { def foo: String = ??? }
val foo2: Foo = new { def foo: String = ??? }
```

While Scala2 semanticdb-plugin emit symbols for the anonymous class.

Lack of the symbol information / occurrence led Metals not being able to
find those anonymous classes as implementations by `go-to-implementation` from `trait Foo`.
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants