Skip to content

Define @static def that is also available on module #19394

Closed
@armanbilge

Description

@armanbilge

Compiler version

3.4.0-RC1-bin-20240106-c15cc9c-NIGHTLY

Minimized code

//> using scala 3.4.0-RC1-bin-20240106-c15cc9c-NIGHTLY

import scala.annotation.static
import scala.annotation.targetName

class Foo

object Foo {
  @static def foo: Foo = ???
  @targetName("foo") def fooBincompat: Foo = foo
}

Output

[error] ./test.scala:10:26
[error] Double definition:
[error] def foo: Foo in object Foo at line 9 and
[error] def fooBincompat: Foo in object Foo at line 10
[error] have the same type (): Foo after erasure.
[error]   @targetName("foo") def fooBincompat: Foo = foo
[error]                          ^

Expectation

I'm seeking a way that we can add the @static annotation post-facto without breaking binary-compatibility. So we need some way to retain or restore the old definition on the module.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions