-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Re-implement NominalTypeDecl::getStoredProperties() using request evaluator #26119
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
Re-implement NominalTypeDecl::getStoredProperties() using request evaluator #26119
Conversation
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
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.
Cooooool
|
||
return name.str().startswith("$__lazy_storage_$_"); |
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.
Ahhhh, thank you!
for (auto I = Range.begin(), E = Range.end(); I != E; ++I, ++Index) { | ||
VarDecl *VD = *I; | ||
const Operand &Op = Operands[Index]; | ||
for (unsigned I = 0, E = Props.size(); I < E; ++I) { |
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.
You know you can write
for (unsigned I : indices(Props))
and we'll all think you're cool
for (auto *varDecl : target->getStoredProperties(/*skipInaccessible=*/true)) { | ||
if (varDecl->getAttrs().hasAttribute<LazyAttr>()) | ||
for (auto *varDecl : target->getStoredProperties()) { | ||
if (!varDecl->isUserAccessible()) |
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.
Hmm. isUserAccessible()
makes sense here, but it's a notion I'd kinda rather throw away at some point. I'm glad it's been pushed down into the clients, since it's a step forward.
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, it might be nice to define it directly at some point (right now I think the only decls with this bit set are backing storage for lazy and wrappers).
isInvalid() is another silly one too that we should replace with something derived from the other properties of the decl.
Build failed |
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
2c43e21
to
78a8f50
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
@swift-ci Please test compiler performance |
Build failed |
Build failed |
The test case crashes because we synthesize the body before validating the function itself. I'm going to add a resolveDeclSignature() call as well to avoid this.
This improves on the previous situation: - The request ensures that the backing storage for lazy properties and property wrappers gets synthesized first; previously it was only somewhat guaranteed by callers. - Instead of returning a range this just returns an ArrayRef, which simplifies clients. - Indexing into the ArrayRef is O(1), which addresses some FIXMEs in the SIL optimizer.
Continue gutting finalizeType() by using our new request to synthesize the backing storage for lazy properties and property wrappers.
78a8f50
to
d0240cc
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
@swift-ci Please test compiler performance |
Also, continue refactoring accessor synthesis, finalizeDecl(), and related code.