Skip to content

@targetName on toplevel class/trait/object fails separate compilation #15066

Closed
@griggt

Description

@griggt

Compiler version

3.2.0-RC1-bin-20220427-b1f00a7-NIGHTLY and earlier

Minimized code

Foo.scala

@annotation.targetName("Bar") class Foo:
  def it: Int = 42

Test.scala

@main def Test = println(Foo().it)

Output

$ scalac Foo.scala
$ scalac Test.scala
-- [E006] Not Found Error: Test.scala:1:25 -------------------------------------
1 |@main def Test = println(Foo().it)
  |                         ^^^
  |                         Not found: Foo
  |
  | longer explanation available when compiling with `-explain`
1 error found

Expectation

I understand that supporting @targetName on class/trait/object is intentional (see #11969 (comment)), thus I would expect such usage to work with separate compilation.

Remarks

No issue with joint compilation.
No issue if Foo is an inner class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions