Skip to content

Commit

Permalink
[QoI] Don't rely on extension type to be present when validating its …
Browse files Browse the repository at this point in the history
…attributes

Malformed 'extension' expressions won't have extended type avaliable,
so don't rely on that when validating its attributes.
  • Loading branch information
xedin committed Dec 5, 2016
1 parent 9197174 commit 1e50570
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckAttr.cpp
Expand Up @@ -289,8 +289,7 @@ 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()))
if (!ED->getAsClassOrClassExtensionContext())
return diagnoseAndRemoveAttr(attr, diag::invalid_ibdesignable_extension);
}
}
Expand Down
Expand Up @@ -5,6 +5,6 @@
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
// REQUIRES: asserts
@IBDesignable extension

0 comments on commit 1e50570

Please sign in to comment.