Skip to content

Annotations import fails when imported in class scope #2109

Closed
@felixmulder

Description

@felixmulder
// Foo.scala
class Foo {
  import foo.Annot

  @Annot def foo = ()
}
// Annot.java
package foo;
import java.lang.annotation.*;

public @interface Annot {}

compiles with:

-- [E006] Unbound Identifier Error: local/test.scala ---------------------------
4 |  @Annot def foo = ()
  |   ^^^^^
  |   not found: type Annot

longer explanation available when compiling with `-explain`
-- Error: local/test.scala -----------------------------------------------------
2 |  import foo.Annot
  |         ^^^
  |         => Unit(Foo.this.foo) is not stable

whereas:

import foo.Annot
class Foo {
  @Annot def foo = ()
}

Compiles just fine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions