Skip to content

Impossible to annotate public primary constructor and keep Scala 2 compatibility #2426

Closed
@smarter

Description

@smarter

This doesn't compile with dotty:

class Foo @deprecated("foo", "2.11.0") (x: Int)
1 |class Foo @deprecated("foo", "2.11.0") (x: Int)
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |    private, protected, or this expected for annotated primary constructor

Adding this does indeed fix it, but doesn't compile with Scala 2:

class Foo @deprecated("foo", "2.11.0") this(x: Int)
  • Is this an intentional difference?
  • If yes, we should at least support the old syntax under -language:Scala2

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