Type parameter clause inference for lambdas (and method references via eta-expansion) #18169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements type parameter clause inference which lets us write a regular lambda where a polymorphic function type is expected:
Additionally, we also allow regular eta-expansion (which adapts a method reference
foo
into an untyped lambdax => foo(x)
) to proceed when the expected type is a polymorphic function type, the untyped lambda can then be adapted into a polymorphic lambda by type parameter clause inference:This is similar to the proposed SIP-49 but instead of inferring the type parameter clause from the method reference we end up inferring it from the expected type, which means we allow the method reference and expected type to have different numbers of type parameters:
TODO: