Skip to content

Commit fd31747

Browse files
committed
Sema: Fix crash with @IBDesignatable attribute on an invalid extension
1 parent e338a50 commit fd31747

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,12 @@ void AttributeEarlyChecker::visitIBActionAttr(IBActionAttr *attr) {
292292

293293
void AttributeEarlyChecker::visitIBDesignableAttr(IBDesignableAttr *attr) {
294294
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
295-
NominalTypeDecl *extendedType = ED->getExtendedType()->getAnyNominal();
296-
if (extendedType && !isa<ClassDecl>(extendedType))
297-
return diagnoseAndRemoveAttr(attr, diag::invalid_ibdesignable_extension);
295+
if (auto extendedType = ED->getExtendedType()) {
296+
if (auto *nominalDecl = extendedType->getAnyNominal()) {
297+
if (!isa<ClassDecl>(nominalDecl))
298+
return diagnoseAndRemoveAttr(attr, diag::invalid_ibdesignable_extension);
299+
}
300+
}
298301
}
299302
}
300303

validation-test/compiler_crashers/28608-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28608-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
do{@IBDesignable extension

0 commit comments

Comments
 (0)