Skip to content

Commit 6b795a4

Browse files
committed
Diagnose lightweight generic classes with objcImpl
Extensions to lightweight generic classes are such a huge mess that we’re just removing these from the feature’s scope for now. Fixes rdar://116066409.
1 parent 81b5d59 commit 6b795a4

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,9 @@ ERROR(attr_objc_implementation_must_have_super,none,
17221722
"'@_objcImplementation' cannot be used to implement root %kind0; declare "
17231723
"its superclass in the header",
17241724
(ValueDecl *))
1725+
ERROR(objc_implementation_cannot_have_generics,none,
1726+
"'@_objcImplementation' cannot be used to implement %kind0",
1727+
(ValueDecl *))
17251728
ERROR(attr_objc_implementation_category_not_found,none,
17261729
"could not find category %0 on Objective-C class %1; make sure your "
17271730
"umbrella or bridging header imports the header that declares it",

lib/Sema/TypeCheckAttr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,12 @@ visitObjCImplementationAttr(ObjCImplementationAttr *attr) {
15101510
return;
15111511
}
15121512

1513+
if (CD->isTypeErasedGenericClass()) {
1514+
diagnoseAndRemoveAttr(attr, diag::objc_implementation_cannot_have_generics,
1515+
CD);
1516+
CD->diagnose(diag::decl_declared_here, CD);
1517+
}
1518+
15131519
if (!attr->isCategoryNameInvalid() && !ED->getImplementedObjCDecl()) {
15141520
diagnose(attr->getLocation(),
15151521
diag::attr_objc_implementation_category_not_found,

test/decl/ext/Inputs/objc_implementation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@
172172

173173
@end
174174

175+
@interface ObjCImplGenericClass<T> : NSObject
176+
177+
@end
178+
175179

176180

177181
struct ObjCStruct {

test/decl/ext/objc_implementation.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ protocol EmptySwiftProto {}
460460
// expected-error@-1 {{'@_objcImplementation' cannot be used to implement root class 'ObjCImplRootClass'; declare its superclass in the header}}
461461
}
462462

463+
@_objcImplementation extension ObjCImplGenericClass {
464+
// expected-error@-1 {{'@_objcImplementation' cannot be used to implement generic class 'ObjCImplGenericClass'}}
465+
}
466+
463467
func usesAreNotAmbiguous(obj: ObjCClass) {
464468
obj.method(fromHeader1: 1)
465469
obj.method(fromHeader2: 2)

0 commit comments

Comments
 (0)