Skip to content

Add IgnoreContextualType fix on Keypath -> Function type mismatch. #31563

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 1 commit into from
May 7, 2020

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented May 5, 2020

When simplifying a KeyPath constraint with a KeyPath type variable bound to a function type, single-parameter function types have the parameter type and the return type matched against the KeyPath root and value types; whereas multiple-parameter functions cause an ambiguous failure (in simplifyKeyPathConstraint).

Resolves rdar://problem/57930643

@artemcm artemcm requested review from xedin and hborla May 5, 2020 16:34
@artemcm
Copy link
Contributor Author

artemcm commented May 5, 2020

In SimplifyKeyPathConstraint, the lambda tryMatchRootAndValueFromType returns false when the function type binding has more than 1 param, without any context. Hence the ambiguous error. If we go with this fix, it can probably be turned into an assert?

If there's a way to provide enough context at the failure site so that the correct error message is emitted, I'd be curious to hear it.

@artemcm
Copy link
Contributor Author

artemcm commented May 5, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented May 5, 2020

Build failed
Swift Test Linux Platform
Git Sha - b008d129c29a04bd546e59e41ec5bd963bc79691

@artemcm artemcm force-pushed the TypeCheckKeypathAsClosure branch from b008d12 to 2f9891b Compare May 6, 2020 04:13
@artemcm artemcm changed the title Do not bind function types with more than 1 parameter to keypaths Add IgnoreContextualType fix on Keypath -> Function type mismatch. May 6, 2020
@artemcm artemcm force-pushed the TypeCheckKeypathAsClosure branch from 2f9891b to 4b6165b Compare May 6, 2020 04:16
@artemcm artemcm requested a review from xedin May 6, 2020 04:16
@artemcm
Copy link
Contributor Author

artemcm commented May 6, 2020

@swift-ci test

@artemcm artemcm force-pushed the TypeCheckKeypathAsClosure branch from 4b6165b to e6901c5 Compare May 6, 2020 21:15
@artemcm artemcm requested a review from xedin May 6, 2020 21:16
@artemcm artemcm force-pushed the TypeCheckKeypathAsClosure branch from e6901c5 to 3ac69a2 Compare May 6, 2020 21:55
When simplifying a keypath constraint with a function type binding, single-parameter functions have the parameter type and the return type matched against the keypath root and value; whereas multiple-parameter functions cause an ambiguous failure (in `simplifyKeyPathConstraint`).

Resolves rdar://problem/57930643
@artemcm artemcm force-pushed the TypeCheckKeypathAsClosure branch from 3ac69a2 to 7aed042 Compare May 7, 2020 02:15
@artemcm
Copy link
Contributor Author

artemcm commented May 7, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented May 7, 2020

Build failed
Swift Test Linux Platform
Git Sha - b008d129c29a04bd546e59e41ec5bd963bc79691

@artemcm artemcm merged commit 3abb0bd into swiftlang:master May 7, 2020
artemcm added a commit to artemcm/swift that referenced this pull request May 8, 2020
…match.

Cherry-pick swiftlang#31563, originally reviewed by @xedin.

When simplifying a keypath constraint with a function type binding, single-parameter functions have the parameter type and the return type matched against the keypath root and value; whereas multiple-parameter functions cause an ambiguous failure (in `simplifyKeyPathConstraint`).

Resolves rdar://problem/57930643
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.

3 participants