You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1|classFoo@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:
classFoo@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
The text was updated successfully, but these errors were encountered:
If the this syntax is intended, then I suggest we also allow it when no annotation is present for consistency, currently this does not compile with dotty:
Based on experimentation, it seems that scalac only allows one parameter list in primary constructor annotations. And while annotations with multiple parameter lists typecheck in other situations, you get an ominous warning:
scala>classFoo(x: Int)(y: String)
defined classFoo
scala>@Foo(1)("foo") classBar(x: Int)
<console>:12:warning: Implementationlimitation: multiple argument lists on annotations are
currently not supported; ignoring arguments List("foo")
@Foo(1)("foo") classBar(x: Int)
^
defined classBar
I suggest formally specifying that annotations constructors can only have one parameter list. That seems to be the status quo in Scala 2 and no one complains about it, and it removes the ambiguity without introducing new syntax.
Uh oh!
There was an error while loading. Please reload this page.
This doesn't compile with dotty:
Adding
this
does indeed fix it, but doesn't compile with Scala 2:-language:Scala2
The text was updated successfully, but these errors were encountered: