Skip to content

[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

Merged
merged 1 commit into from
May 7, 2021

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 5, 2021

Emit ParamDecl::getPropertyWrapperAuxiliaryVariables() variables instead of the param itself.

rdar://76355405

@rintaro
Copy link
Member Author

rintaro commented May 5, 2021

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented May 5, 2021

@hborla AFAICT, VarDecls in PropertyWrapperAuxiliaryVariables for ParamDecl are not placed in the body of the function, nor visited by ASTWalker. Could you just verify that this is the intended behavior?

@rintaro rintaro requested review from hborla and benlangmuir May 5, 2021 22:38
@hborla
Copy link
Member

hborla commented May 5, 2021

AFAICT, VarDecls in PropertyWrapperAuxiliaryVariables for ParamDecl are not placed in the body of the function, nor visited by ASTWalker. Could you just verify that this is the intended behavior?

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.

@rintaro
Copy link
Member Author

rintaro commented May 5, 2021

Yes, that's intended behavior

Thanks!

This is also the case for property wrappers on local variables.

Ohhh, thanks for remind me about "property wrappers on local variables". I support it in this PR too.

@@ -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.
Copy link
Member

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

auto vars = param->getPropertyWrapperAuxiliaryVariables();
checkValueDecl(vars.localWrappedValueVar,
DeclVisibilityKind::FunctionParameter);
checkValueDecl(vars.projectionVar, DeclVisibilityKind::FunctionParameter);
Copy link
Contributor

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.

Copy link
Member Author

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().

@rintaro rintaro force-pushed the ide-completon-se0293-rdar76355405 branch from 19a4d2a to a01a3ad Compare May 6, 2021 20:21
@rintaro
Copy link
Member Author

rintaro commented May 6, 2021

@swift-ci Please smoke test

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