-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The expected way to deprecate an implicit class doesn't work #10152
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10152?orig=1 |
@som-snytt said: Explicit def is not allowed: scala> @deprecated("nope","forever") def C(i: Int) = new C(i) ; implicit class C(i: Int) { def doubled = i * 2 }
<console>:12: error: method C is defined twice;
the conflicting method C was defined at line 12:42
@deprecated("nope","forever") def C(i: Int) = new C(i) ; implicit class C(i: Int) { def doubled = i * 2 }
^ |
Not sure if it is the expected usage |
The workaround does not cover "don't warn if enclosing element is deprecated"; we need the annotation on the class:
|
volunteer to fix this? this is a pretty darn bad bug, IMO note that you don't even have to invoke the implicit conversion, there is no deprecation warning regardless: scala 2.13.4> @deprecated("","") class C(x: AnyRef) { def foo = 3 }
class C
scala 2.13.4> (new C(new AnyRef)).foo
^
warning: class C is deprecated:
val res16: Int = 3
scala 2.13.4> @deprecated("","") implicit class C(x: AnyRef) { def foo = 3 }
class C
scala 2.13.4> new C(new AnyRef)
val res18: C = C@36358417 |
I'm going to look into this. |
scala> @(deprecated @companionMethod)("bye", "forever") @(deprecated @companionClass)("dead", "now") implicit class Foo(i: Int) { def bar = i }
class Foo
scala> 1.bar
^
warning: method Foo is deprecated (since forever): bye
val res0: Int = 1
scala> new Foo(1).bar
^
warning: class Foo is deprecated (since now): dead
val res1: Int = 1 Personally I think |
It changed from "no way to deprecate an implicit class" to "many unexpected ways" to do it. |
The text was updated successfully, but these errors were encountered: