Open satorg opened 1 month ago
The Scala 3 check was intentionally skipping the type parameter, but inadvertently skipping the annotation.
The rename was not germane.
Worth adding that Scala 2:
$ scalac -d /tmp/sandbox -Xlint i20536.scala
i20536.scala:3: warning: type parameter Int defined in trait ImportUnusedSpecializedRename shadows class Int defined in package scala. You may want to rename your type parameter, or possibly remove it.
trait ImportUnusedSpecializedRename[@sp Int]
^
1 warning
Scala 3
$ scalac -d /tmp/sandbox -Wshadow:all i20536.scala
-- Warning: i20536.scala:3:40 ------------------------------------------------------------------------------------------
3 |trait ImportUnusedSpecializedRename[@sp Int]
| ^^^^^^^
| Type parameter Int for trait ImportUnusedSpecializedRename shadows the type defined by class Int in package scala
1 warning found
Ah, sorry, I overworked it a little. In Cats it is a generic A
, not Int
:
https://github.com/typelevel/cats/blob/90db3cd0269cf2b621ad6460ded594aee2e6a135/kernel/src/main/scala/cats/kernel/Enumerable.scala#L25-L34
I didn't intend to rub it in. My point was going to be that scala 2 will lint that, but then I looked and scala 3 does it now too. I'll have to find some other clever thing to point out.
Compiler version
v3.3.3, v3.4.2
Minimized code
Script that I used for testing:
Output
Expectation
Scala3 should compile the above example without the "unused import" warnings. As long as Scala2 compilers can do.
Additional Information
This issues causes a lot of extra warnings added up while compiling Cats for Scala3. Historically, Cats uses
import scala.{specialized => sp}
in a bunch of files across the repository.