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
Expansion of wildcard to existential type ignores bound #2385
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2385?orig=1 |
@cunei said: The syntax You can just write |
Kris Nuttycombe (nuttycom) said: The syntax A[_] is equivalent to A[T] forsome { type T >: scala.Nothing <: scala.Any }. In this case, shouldn't the declaration val a: A[_] be a type error? |
@cunei said: To make an analogy, if I tell you "I will arrive on Monday, because I can only arrive on Mondays", and in turn you tell to someone else "He will arrive on some weekday", your assertion is still valid. |
Given the following:
compilation fails as:
even though it is not possible for any instance of A to fail to satisfy this bound. Explicitly specifying the existential type allows correct compilation:
It seems like A[_] is naively being expanded to A[T] forSome {type T} instead of respecting the bound declared in A. Minor, but unexpected.
The text was updated successfully, but these errors were encountered: