-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Update for SE-0293 Property Wrappers for func params #37280
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
[CodeCompletion] Update for SE-0293 Property Wrappers for func params #37280
Conversation
@swift-ci Please smoke test |
@hborla AFAICT, |
Yes, that's intended behavior (although it might be nice to refactor this to put the visiting functionality in ASTWalker and make it configurable). This is also the case for property wrappers on local variables. |
Thanks!
Ohhh, thanks for remind me about "property wrappers on local variables". I support it in this PR too. |
lib/AST/NameLookup.cpp
Outdated
@@ -2758,6 +2758,21 @@ void FindLocalVal::checkPattern(const Pattern *Pat, DeclVisibilityKind Reason) { | |||
|
|||
void FindLocalVal::checkParameterList(const ParameterList *params) { | |||
for (auto param : *params) { | |||
if (param->hasAttachedPropertyWrapper()) { | |||
// FIXME: This shouldn't be needed, but only this set the interface type | |||
// of the auxiliary variables. |
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.
The reason why PropertyWrapperAuxiliaryVariablesRequest
does not set the interface type of auxiliary variables is because is because for closures, the interface types are inferred and set by the constraint system. There are more details and test cases that rely on this behavior in #36521
lib/AST/NameLookup.cpp
Outdated
auto vars = param->getPropertyWrapperAuxiliaryVariables(); | ||
checkValueDecl(vars.localWrappedValueVar, | ||
DeclVisibilityKind::FunctionParameter); | ||
checkValueDecl(vars.projectionVar, DeclVisibilityKind::FunctionParameter); |
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 think we need to check at least projectionVar for null. Not sure about the other two -- they seem like they're intended to not be null, but I'm not sure what happens in invalid code.
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.
Yeah, I changed to check all of them, just in case.
Also, to support local variables, I moved the logic into checkValueDecl()
.
19a4d2a
to
a01a3ad
Compare
@swift-ci Please smoke test |
Emit
ParamDecl::getPropertyWrapperAuxiliaryVariables()
variables instead of the param itself.rdar://76355405