Skip to content

Backport "Restrict captureWildcards to only be used if needed" #16929

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

Closed
wants to merge 4 commits into from

Conversation

Kordyjan
Copy link
Contributor

Backports #16799 and #16732

The first PR was marked as needing backporting to 3.3.0 even though it fixed a regression that first appeared after branching off the release branch for 3.3.0. It relied on the changes from #16732, so I also cherry-picked them.

I don't remember exactly why we decided to backport those changes, so I'm leaving it to @dwijnand to decide.

Rather than blindly using the newly wildcard-captured type, check that
it's compatible with the proto/formal type.  That way values that have
wildcard types can be passed, uncast, to extension methods that don't
require the capture.

For instance in specs2, a value of type `Class[? <: Foo]` needn't become
`Class[?1.CAP]` just so it can be applied to `def theValue[T](t: => T)`.

For the zio-http case, despite knowing that JFuture is morally
covariant, we don't have any way to knowing that - so we must be safe
and error.
@dwijnand
Copy link
Member

I was confused by #16789, but that's a regression against main, not against the 3.3.0 release. And the underlying issue is really niche, so it needn't be fast-tracked.

@dwijnand dwijnand closed this Feb 16, 2023
@dwijnand dwijnand deleted the backport-16799 branch February 16, 2023 10:29
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