Skip to content

Hover on annotation in Scala just shows the Ref it's on #3593

@ckipp01

Description

@ckipp01

Describe the bug

Having a minimal piece of code like this:

import scala.annotation.nowarn

@no@@warn
class Foo

When you attempt to do a hover on @nowarn you actually get the TypeRef of Foo shown instead of the information about @nowarn.

Screenshot 2022-02-01 at 10 48 01

The tree that is returned here for this pos is:

TypeDef(
  name = Foo,
  rhs = Template(
    constr = DefDef(
      name = <init>,
      paramss = List(List()),
      tpt = TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],
      preRhs = Thicket(trees = List())
    ),
    parentsOrDerived = List(
      Apply(
        fun = Select(
          qualifier = New(
            tpt = TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]
          ),
          name = <init>
        ),
        args = List()
      )
    ),
    self = ValDef(name = _, tpt = Thicket(trees = List()), preRhs = Thicket(trees = List())),
    preBody = List()
  )
)

I actually stumbled onto this because of something else (trying to understand when I'd see the Annotated tree) and then realizing I could never see it when testing with untyped trees or typed ones. Then I looked at how Metals would show this, and it also doesn't show the annotation. Is this actually an updates issue that Annotated is never in the tree?

Expected behavior

I'd expect that this show the signature and scaladocs for @nowarn instead of for Foo.

Operating system

macOS

Editor/Extension

Nvim (nvim-metals)

Version of Metals

0.11.1+47-66ea31ef-SNAPSHOT

Extra context or search terms

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Scala 3Generic ticket relating to Scala 3presentation-compilerSomething relating to the presentation compiler

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions