Skip to content

Rely on variance to typecheck more uses of wildcards #6719

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

Merged
merged 2 commits into from
Jun 21, 2019

Conversation

smarter
Copy link
Member

@smarter smarter commented Jun 20, 2019

If we can't capture the wildcard argument, we might still be able to
return true to the subtype check by approximating the wildcard based on
variance.

@smarter smarter force-pushed the wildcard-sub branch 2 times, most recently from f77c419 to a24e86a Compare June 20, 2019 15:42
smarter added 2 commits June 20, 2019 18:21
If we can't capture the wildcard argument, we might still be able to
return true to the subtype check by approximating the wildcard based on
variance.

This leads to a regression in t5729 were two overloads are now
considered ambiguous, but the only reason they were not ambiguous before
was that the subtype test failed when it shouldn't, so this seems
acceptable.
Because of the previous commit,
tests/fuzzy/AE-9a131723f09b9f77c99c52b709965e580a61706e.scala now passes
the typer, but then crashes in ExpandSAMs because we attempt to create
an anonymous class whose parent is `PartialFunction[_, Int]` and
tpd.ClassDef does not handle wildcard arguments. We avoid this issue by
getting the argument types for the parent from the closure DefDef whose
parameter and result types can never be wildcards.
@odersky odersky merged commit acb1ffd into scala:master Jun 21, 2019
@allanrenucci allanrenucci deleted the wildcard-sub branch June 21, 2019 09:48
@smarter smarter mentioned this pull request Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants