scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.83k stars 1.05k forks source link

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

Closed tanishiking closed 2 years ago

tanishiking commented 2 years ago

Originally reported https://github.com/scalameta/metals/issues/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 commented 2 years ago

I'm working on it :)