-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #6146: Fix bounds check involving wildcards and f-bounds #6147
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
Conversation
Don't map arguments to their upper bounds before doing the bound check. There was a comment justifiying that by talking about non fully-determined arguments, but this check is done in PostTyper when all types should already be fully-determined. Given that this comment was written in 2014 I'm assuming it's no longer relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was quick! I think it needs to be tweaked though. "Undetermined argument" in the comment means wildcard, which can well happen in PostTyper.
What we need here looks like another (simple) instance of capture conversion. I.e. replace any TypeBounds argument L..U
by a skolem $n.CAP
, where $n
is of type TypeBox[L, U]
.
Hmm, I'm having trouble coming up with an example where this would make a difference and our tests are green, can you take over this PR or come up with an example ? |
Isn't the existing wildcard capture logic in subtyping going to do that for us ? |
Use substApprox for F-bounds instantiation if there are wildcards. This is the simplest checking algorithm I could find that is not obviously wrong and that accepts i6146.scala. I can't prove it's correct, though.
In fact, thinking more about it the last commit 48f7ed6 still feels wrong. The only way to deal with wildcards consistently is by skolemizing them in one way or another. |
This reverts commit 48f7ed6.
Revised scheme for checking applied types containing wildcards in F-bounds.
With skolemization we fail compiling the standard lib with: ``` [E057] Type Mismatch Error: /Users/odersky/workspace/dotty/tests/scala2-library/src/library/scala/collection/generic/ParMapFactory.scala:28:76 28 |abstract class ParMapFactory[CC[X, Y] <: ParMap[X, Y] with ParMapLike[X, Y, CC[X, Y], _]] | ^ |Type argument CC[X, Y] does not conform to upper bound scala.collection.parallel.ParMapLike[X, Y, LazyRef(CC[X, Y]), | collection.parallel.ParMapLike[X, Y, CC[X, Y], _]#Sequential |] & scala.collection.parallel.ParMap[X, Y] -- ``` I have no idea whether this bound is correct or not, and am not inclined to find out. But we clearly have to support it anyway under Scala-2 mode.
It's hard to identify the point where we should issue such a warning. Also there's no good guideline we could give. |
Don't map arguments to their upper bounds before doing the bound check.
There was a comment justifiying that by talking about non
fully-determined arguments, but this check is done in PostTyper when all
types should already be fully-determined. Given that this comment was
written in 2014 I'm assuming it's no longer relevant.