Skip to content

Commit 7146454

Browse files
committed
Do not crash on @objc (Name) extension FancyName {}
We accepted this in Xcode 9.2, but currently crash. We may want to consider rejecting this entirely, but for now lets not crash. Fixes rdar://problem/36798061. (cherry picked from commit a499762)
1 parent c54efad commit 7146454

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9159,7 +9159,8 @@ static void validateAttributes(TypeChecker &TC, Decl *D) {
91599159
// appropriate.
91609160
if (auto objcName = objcAttr->getName()) {
91619161
if (isa<ClassDecl>(D) || isa<ProtocolDecl>(D) || isa<VarDecl>(D)
9162-
|| isa<EnumDecl>(D) || isa<EnumElementDecl>(D)) {
9162+
|| isa<EnumDecl>(D) || isa<EnumElementDecl>(D)
9163+
|| isa<ExtensionDecl>(D)) {
91639164
// Types and properties can only have nullary
91649165
// names. Complain and recover by chopping off everything
91659166
// after the first name.

test/attr/attr_objc.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ protocol Protocol_Class2 : class {}
3232

3333
@objc extension PlainStruct { } // expected-error{{'@objc' can only be applied to an extension of a class}}{{1-7=}}
3434

35+
class FáncyName {}
36+
@objc (FancyName) extension FáncyName {}
37+
3538
@objc
3639
var subject_globalVar: Int // expected-error {{@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes}}
3740

0 commit comments

Comments
 (0)