-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Default arguments: implement captures for local functions, diagnose 'Self' for methods #27220
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
Default arguments: implement captures for local functions, diagnose 'Self' for methods #27220
Conversation
@swift-ci Please smoke test |
@@ -5164,6 +5164,7 @@ class ParamDecl : public VarDecl { | |||
PointerUnion<Expr *, VarDecl *> DefaultArg; | |||
Initializer *InitContext = nullptr; | |||
StringRef StringRepresentation; | |||
CaptureInfo Captures; |
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.
This is, uh, kind of expensive to put in every default argument, no?
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.
I guess, but I don't think there are that many default arguments. We can shrink it down to the size of a single ArrayRef with a bit of work though.
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.
Maybe you'll have successfully nerd-sniped me into it after all!
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.
Hah, you're more than welcome to. I have another commit I'm going to tack onto this PR that implements default argument captures for local functions -- it wasn't too hard after all. Might want to wait for that one to avoid too many merge conflicts
…ature This also fixes a long-standing bug with default argument expressions capturing generic parameters.
…expressions We could actually allow this for local functions, but it's not worth implementing that until the more general ability of local function default arguments to capture values is implemented. Fixes <rdar://problem/55119566>.
…res generic parameters
…nRefs Unfortuantely this commit is bigger than I would like but I couldn't think of any reasonable ways to split it up. The general idea here is that capture computation is now done for a SILDeclRef and not an AnyFunctionRef. This allows SIL to represent the captures of a default argument generator.
Fixes <https://bugs.swift.org/browse/SR-2189>, <rdar://problem/20796451>.
9534b07
to
78ae7ac
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
…ult-arg-captures Changelog entry for #27220
I'll add a changelog entry in a new PR since I've already started tests on this one. This fixes stuff like
Fixes https://bugs.swift.org/browse/SR-2189, rdar://problem/20796451, rdar://problem/55119566.