Skip to content

[ConstraintSystem] Form argument constraints instead of using `matchT… #19699

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

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Oct 3, 2018

…ypes` directly

Forming constraints instead of using matchTypes while matching argument/parameter
types makes sure that failedConstraint points to failed argument conversion
instead of applicable function constraint, which is better for diagnostics.

…ypes` directly

Forming constraints instead of using `matchTypes` while matching argument/parameter
types makes sure that `failedConstraint` points to failed argument conversion
instead of `applicable function` constraint, which is better for diagnostics.
@xedin xedin requested a review from rudkx October 3, 2018 22:48
@xedin
Copy link
Contributor Author

xedin commented Oct 3, 2018

@swift-ci please smoke test

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -56,7 +57,7 @@ func takesNoEscapeClosure(_ fn : () -> Int) {
takesGenericClosure(4) { fn() } // ok.

_ = [fn] // expected-error {{converting non-escaping value to 'Element' may allow it to escape}}
_ = [doesEscape(fn)] // expected-error {{'(() -> Int) -> ()' is not convertible to '(@escaping () -> Int) -> ()'}}
_ = [doesEscape(fn)] // expected-error {{passing non-escaping parameter 'fn' to function expecting an @escaping closure}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -848,9 +844,7 @@ ConstraintSystem::TypeMatchResult constraints::matchCallArguments(
getApplyArgToParam(argIdx,
paramIdx));
auto argTy = argsWithLabels[argIdx].getOldType();
Copy link
Contributor

@slavapestov slavapestov Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A possible next step here: if this is an InOutType, the argument conversion immediately simplifies down to a BindParam. You could instead directly emit a BindParam here, bypassing the existence of InOutType altogether. This allows you to replace the getOldType() call with getPlainType()

@xedin xedin merged commit 883efed into swiftlang:master Oct 4, 2018
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