-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
unhelpful warning for unsupported Scala 2 existential types #13873
Comments
here is a reproducer: compile with Scala 2 to import language.existentials
abstract class Box[T]
object Box {
def foo(b: Box[x forSome { type x }]) = ???
} compile with Scala 3 with @main def Test =
Box.foo(???) producing the uninformative error:
|
if you are migrating perhaps it will work to replace all |
Also I would assume that we should be able to treat |
What's the use case for this, I wonder? |
Note it's not equivalent to a wildcard.
|
We used this pattern a lot. It was the way we would get code like this to compile: def compare(x: Comparable[_], y: Comparable[_]): Int = {
type T = x forSome { type x }
x.asInstanceOf[Comparable[T]].compareTo(y.asInstanceOf[Comparable[T]])
} Without the casts, you get
I know you can also do x.asInstanceOf[Comparable[Any]].compareTo(y.asInstanceOf[Comparable[Any]]) in this case, but I'm pretty sure that doesn't work if there are type bounds on the type parameter. Declaring an explicit type variable also just seems less like a hack. Is there a better way? |
Compiler version
3.1.0
Minimized code
Not sure, but I have a Scala 3 sbt project that depends on a Scala 2.13 project.
Output
Expectation
The error message would ideally tell me which Scala-2 classfile the symbol came from, or which Scala-3 compilation unit the reference is happening in (or both). We use
x forSome type x
dozens of times in our Scala code so I can't narrow down where the error is coming from.The text was updated successfully, but these errors were encountered: