Skip to content
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

[QoI] Don't rely on extension type to be present when validating its attributes #6065

Closed
wants to merge 1 commit into from

Conversation

xedin
Copy link
Member

@xedin xedin commented Dec 5, 2016

Malformed 'extension' expressions won't have extended type avaliable,
so don't rely on that when validating its attributes.

@xedin
Copy link
Member Author

xedin commented Dec 5, 2016

/cc @rudkx @DougGregor

@@ -290,7 +290,8 @@ void AttributeEarlyChecker::visitIBActionAttr(IBActionAttr *attr) {
void AttributeEarlyChecker::visitIBDesignableAttr(IBDesignableAttr *attr) {
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
CanType extendedTy = ED->getExtendedType()->getCanonicalType();
if (!isa<ClassDecl>(extendedTy->getAnyNominal()))
auto nominalType = extendedTy->getAnyNominal();
if (!nominalType || !isa<ClassDecl>(nominalType))
Copy link
Member

Choose a reason for hiding this comment

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

Even better:

if (auto classDecl = ED->getAsClassOrClassExtensionContext())

Copy link
Member Author

@xedin xedin Dec 5, 2016

Choose a reason for hiding this comment

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

Thanks for the suggestion! I actually made it that way because I wanted to diagnose in-place if the type is NULL as well, which is not going to happen if I use if (auto classDecl = ED->getAsClassOrClassExtensionContext())

Copy link
Member

Choose a reason for hiding this comment

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

I think they should be equivalent.

…attributes

Malformed 'extension' expressions won't have extended type avaliable,
so don't rely on that when validating its attributes.
@xedin
Copy link
Member Author

xedin commented Dec 5, 2016

@slavapestov Done!

@DougGregor
Copy link
Member

@swift-ci please smoke test and merge

@xedin
Copy link
Member Author

xedin commented Dec 5, 2016

@DougGregor since #6072 got merged, I am closing this one.

@xedin xedin closed this Dec 5, 2016
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.

None yet

3 participants