-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST/Sema] Associate @autoclosure
flag with parameter declaration
#20152
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
[AST/Sema] Associate @autoclosure
flag with parameter declaration
#20152
Conversation
6034e41
to
642caa5
Compare
@autoclosure
flag with parameter declaration@autoclosure
flag with parameter declaration
The way I wanted to change parser didn't work out so I think this is really for review, because I can add some more tests to |
@swift-ci please clean test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test source compatibility |
b2c2666
to
d6fc3cf
Compare
@swift-ci please test |
@swift-ci please test Linux platform |
@swift-ci please test macOS platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It's a pretty big change and could probably use another pair of eyes, though!
e4c2288
to
fa306b1
Compare
@swift-ci please test |
@swift-ci please test |
Build failed |
a31137d
to
9a4b6ba
Compare
If there are no other problems, I'll soon make changes to |
/cc @moiseev XCTest overlay was doing a lot of @autoclosure <-> @autoclosure conversions which I fixed by calling |
cc @stmontgomery too (about XCTest) |
@@ -146,17 +146,17 @@ public func XCTAssertNil(_ expression: @autoclosure () throws -> Any?, _ message | |||
if !passed { | |||
// TODO: @auto_string expression | |||
|
|||
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr as NSString), message, file, line) | |||
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, expressionValueStr as NSString), message(), file, line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to remove @autoclosure
from the message:
parameter of the _XCTRegisterFailure
helper function, now? Are there any remaining use cases for that to be @autoclosure
?
/cc @briancroom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that _XCTRegisterFailure
unconditionally evaluates the message
parameter, I doubt there's any need for it to actually be an autoclosure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you guys want me to make that change or would you handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: XCTest as well as the majority of other overlays is built in Swift 4 mode, and so this change is not strictly required. Thanks @xedin for fixing it anyways. LGTM, removing an autoclosure completely also works, and can probably be done separately.
Build failed |
It should become a declaration attribute instead, but it can't be done at the moment because `@autoclosure` is a type attribute.
`typeCheckParameterDefault` is used to type-check default value expression associated with a given parameter. It makes it possible to look-through `@autoclosure` function to use its result as contextual type, and later build implicit autoclosure expression if needed.
Make sure that presence of `@autoclosure` attribute handled in one place - `matchCallArguments`, which makes it possible to remove the rest of (now redundant) autoclosure related logic scattered throughout solver.
There is one place which handles `@autoclosure` attribute associated with parameters - `matchCallArguments`.
…arameter flags There is only one place where we need to do that - `typeCheckArgumentChildIndependently`
Mangled implicit closures shouldn't have `@autoclosure` flag associated with them, because their type is just a regular function type.
…ity mode Swift versions < 5 allowed argument passed to @autoclosure parameter to be @autoclosure function type, we need to make sure that such behavior is preserved.
… < 5 Since it was allowed to pass function types to @autoclosure parameters in Swift versions < 5, it has to be handled as a regular function coversion by `coerceToType`.
c106e54
to
7bd2688
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
Build failed |
Build failed |
Source compat failure with |
Looks like with all these rebases I've lost commit with added tests Slava requested me to add, going to add them in follow-up commit... |
These changes aim to:
@autoclosure
flag from function type to parameter declaration@autoclosure
as part of the parameter declarationAnyFunctionType::ExtInfo
@autoclosure
handlingand clarify overloading behavior
Resolves: rdar://problem/30906031