Skip to content

Parsing generic subscripts #7697

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 3 commits into from
Feb 24, 2017

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Feb 23, 2017

Now that #7683 has landed, this adds parser support. The only tricky thing here is that since accessors for a subscript are not nested inside the subscript itself, we have to clone the generic parameter list of the subscript for each accessor, since otherwise name lookup won't find the generic parameters.

The main thing that remains now is SILGen support. Some simple examples I tried work, but I need to exercise the corner cases more, in particular materializeForSet, and actually write proper tests.

// Code completion for the generic type params.
//
// FIXME: What is this?
if (GPHasCodeCompletion)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nkcsgexi How do I test these 'code completion' code paths in the parser correctly?

@slavapestov slavapestov force-pushed the parsing-generic-subscripts branch from 2f0d81c to 86cd479 Compare February 23, 2017 06:05
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Good start!

lib/AST/Decl.cpp Outdated
for (auto param : getParams()) {
auto *decl = new (ctx) GenericTypeParamDecl(
dc, param->getName(), param->getNameLoc(),
0xFFFF, param->getIndex());
Copy link
Member

Choose a reason for hiding this comment

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

Okay, this is my fault, but that 0xFFFF should probably become a named constant.

@@ -4813,6 +4813,17 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
}
}

#if 0
Copy link
Member

Choose a reason for hiding this comment

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

seems like we'll need this?

@slavapestov slavapestov force-pushed the parsing-generic-subscripts branch from 86cd479 to 41c965b Compare February 23, 2017 23:00
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov force-pushed the parsing-generic-subscripts branch from 41c965b to b5d7d2d Compare February 24, 2017 01:26
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

This will be immediately needed for generic subscripts, and also
for fixing the remaining cases where initializer inheritance
doesn't work.
@slavapestov slavapestov force-pushed the parsing-generic-subscripts branch from b5d7d2d to 9c91181 Compare February 24, 2017 04:57
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov force-pushed the parsing-generic-subscripts branch from 9c91181 to 928a74c Compare February 24, 2017 05:14
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@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.

2 participants