-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Parsing generic subscripts #7697
Conversation
// Code completion for the generic type params. | ||
// | ||
// FIXME: What is this? | ||
if (GPHasCodeCompletion) |
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.
@nkcsgexi How do I test these 'code completion' code paths in the parser correctly?
2f0d81c
to
86cd479
Compare
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.
Good start!
lib/AST/Decl.cpp
Outdated
for (auto param : getParams()) { | ||
auto *decl = new (ctx) GenericTypeParamDecl( | ||
dc, param->getName(), param->getNameLoc(), | ||
0xFFFF, param->getIndex()); |
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.
Okay, this is my fault, but that 0xFFFF should probably become a named constant.
lib/Sema/TypeCheckDecl.cpp
Outdated
@@ -4813,6 +4813,17 @@ class DeclChecker : public DeclVisitor<DeclChecker> { | |||
} | |||
} | |||
|
|||
#if 0 |
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.
seems like we'll need this?
86cd479
to
41c965b
Compare
@swift-ci Please smoke test |
41c965b
to
b5d7d2d
Compare
@swift-ci Please smoke test |
1 similar comment
@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.
b5d7d2d
to
9c91181
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
9c91181
to
928a74c
Compare
@swift-ci Please smoke test |
1 similar comment
@swift-ci Please smoke test |
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.