Skip to content

Backport "Properly handle SAM types with wildcards" to LTS #19112

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
Dec 8, 2023

Conversation

Kordyjan
Copy link
Contributor

Backports #18201 to the LTS branch.

PR submitted by the release tooling.

Kordyjan and others added 2 commits November 30, 2023 17:07
Previously there were two separate checks for contextual function types as
result types: one in SAMType for non-PartialFunctions and one in ExpandSAM for
PartialFunctions. This is replaced by a single check (with a detailed error
message like we already had for PartialFunctions).

[Cherry-picked 18f90d9][modified]
[Cherry-picked 89735d0][modified]

When typing a closure with an expected type containing a wildcard, the closure
type itself should not contain wildcards, because it might be expanded to an
anonymous class extending the closure type (this happens on non-JVM backends as
well as on the JVM itself in situations where a SAM trait does not compile down
to a SAM interface).

We were already approximating wildcards in the method type returned by the
SAMType extractor, but to fix this issue we had to change the extractor to
perform the approximation on the expected type itself to generate a valid
parent type. The SAMType extractor now returns both the approximated parent
type and the type of the method itself.

The wildcard approximation analysis relies on a new `VarianceMap` opaque type
extracted from Inferencing#variances.

Fixes #16065.
Fixes #18096.
Base automatically changed from lts-18178 to release-3.3.2 December 8, 2023 15:19
@Kordyjan
Copy link
Contributor Author

Kordyjan commented Dec 8, 2023

No regressions detected in the community build up to lts-16941.

Reference

@Kordyjan Kordyjan merged commit 66f8992 into release-3.3.2 Dec 8, 2023
@Kordyjan Kordyjan deleted the lts-18201 branch December 8, 2023 15:19
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