-
Notifications
You must be signed in to change notification settings - Fork 10.5k
IRGen: We need to make not of any parent decl in nested type decls #16135
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
IRGen: We need to make not of any parent decl in nested type decls #16135
Conversation
Such that we emit the parent's type metadata rdar://39648725
@swift-ci Please test |
…ecls Such that we emit the parent's type metadata rdar://39648725 Cherry-pick from swiftlang#16135
…ecls Such that we emit the parent's type metadata rdar://39648725 Cherry-pick from swiftlang#16135
lib/IRGen/GenMeta.cpp
Outdated
void IRGenerator::noteUseOfAnyParentTypeMetadata(NominalTypeDecl *type) { | ||
// If this is a nested type we also potentially might need the outer types. | ||
auto *declCtxt = type->getDeclContext(); | ||
assert(declCtxt); |
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.
This assertion is not needed. The type will never be null, and if it is, you will crash below.
lib/IRGen/GenMeta.cpp
Outdated
// If this is a nested type we also potentially might need the outer types. | ||
auto *declCtxt = type->getDeclContext(); | ||
assert(declCtxt); | ||
auto *parentNominalDecl = dyn_cast_or_null<NominalTypeDecl>(declCtxt); |
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.
On the other hand, this will fail if the type is defined inside an extension. Instead, use declCtxt->getAsNominalTypeOrNominalTypeExtensionContext()
.
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.
Will do.
} | ||
} | ||
|
||
struct Outer3 { |
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.
Please add some tests involving extensions.
rdar://39648725
@swift-ci Please test |
Build failed |
Build failed |
Such that we emit the parent's type metadata
rdar://39648725