Skip to content

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

Merged

Conversation

aschwaighofer
Copy link
Contributor

Such that we emit the parent's type metadata

rdar://39648725

Such that we emit the parent's type metadata

rdar://39648725
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

aschwaighofer added a commit to aschwaighofer/swift that referenced this pull request Apr 24, 2018
…ecls

Such that we emit the parent's type metadata

rdar://39648725

Cherry-pick from swiftlang#16135
aschwaighofer added a commit to aschwaighofer/swift that referenced this pull request Apr 24, 2018
…ecls

Such that we emit the parent's type metadata

rdar://39648725

Cherry-pick from swiftlang#16135
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);
Copy link
Contributor

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.

// 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);
Copy link
Contributor

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

}
}

struct Outer3 {
Copy link
Contributor

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.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a830acd

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a830acd

@aschwaighofer aschwaighofer merged commit 64ca7c3 into swiftlang:master Apr 24, 2018
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.

3 participants