Skip to content
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

Fix #8802: Use wildcards for result type approximation of implicits #8824

Merged
merged 4 commits into from
Apr 28, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 28, 2020

Use wildcards for result type approximation of dependent implicit methods.
In a situation like

  def f(using x: T): C[x.Out]

we need to go constrain the result type of f before doing the implicit
search for T. Previously we created a fresh type variable param(1) with
T & Singleton as upper bound. That works well for other uses of
result type approximation, but in this case, we miss constraining
param(1) from below by the result of the implicit search. So in the end
param(1) gets interpolated to its upper bound, which leads to problems.

One possible solution is to add the missing lower constraint for the dependent
type variable. But it's easier to just use a Wildcard type, which is what
this PR does.

Use wildcards for result type approximation of dependent implicit methods.
In a situation like
```
  def f(using x: T): C[x.Out]
```
we need to go constrain the result type of `f` before doing the implicit
search for `T`. Previously we created a fresh type variable `param(1)` with
`T & Singleton` as upper bound. That works well for other uses of
result type approximation, but in this case, we miss constraining
`param(1)` from below by the result of the implicit search. So in the end
`param(1)` gets interpolated to its upper bound, which leads to problems.

One possible solution is to add the missing lower constraint for the dependent
type variable. But it's easier to just use a Wildcard type, which is what
this PR does.
@odersky
Copy link
Contributor Author

odersky commented Apr 28, 2020

Also fixes #8825

@odersky odersky merged commit d436677 into scala:master Apr 28, 2020
@odersky odersky deleted the fix-#8802 branch April 28, 2020 21:31
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