-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST] Requestify local type declarations #70737
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
Conversation
Instead of recording local type declarations while parsing, make a request to collect them from the AST. This reduces the side effect of parsing.
@swift-ci Please smoke test |
@swift-ci Please Test Source Compatibility |
case DeclKind::Struct: | ||
case DeclKind::Class: | ||
case DeclKind::Protocol: | ||
case DeclKind::TypeAlias: |
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'm not really sure we need TypeAlias
here. IRGen and SILGen don't seem to handle them. Maybe isa<NominalTypeDecl>(D)
might be better?
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.
It seems reasonable to keep type aliases here so that this request returns all local types, even if IRGen and SILGen don't care. Debugging and module emission probably care, for example.
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.
Fantastic, thank you!
case DeclKind::Struct: | ||
case DeclKind::Class: | ||
case DeclKind::Protocol: | ||
case DeclKind::TypeAlias: |
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.
It seems reasonable to keep type aliases here so that this request returns all local types, even if IRGen and SILGen don't care. Debugging and module emission probably care, for example.
@@ -1444,7 +1444,8 @@ void SourceFile::getPrecedenceGroups( | |||
} | |||
|
|||
void SourceFile::getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results) const { |
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 might be missing a reference, but I believe the only two uses of this can just be replaced with getLocalTypeDecls()
- neither use mutates the vector after retrieving them.
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.
Module::getLocalTypeDecl()
calls FileUnit::getLocalTypeDecls(SmallVectorImpl<TypeDecl*>)
. Since SerializedASTFile
doesn't hold them as a list of TypeDecl *
we can't simply make it return ArrayRef
.
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.
Nice!
Instead of recording local type declarations while parsing, make a request to collect them from the AST.
This reduces the side effect of parsing.