Skip to content

Commit 23bc322

Browse files
committed
Ban the use of @_staticInitializeObjCMetadata; it's an implementation detail.
1 parent 6ceb47b commit 23bc322

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ DECL_ATTR(NSKeyedArchiveLegacy, NSKeyedArchiveLegacy,
278278
/*Not serialized */ 68)
279279

280280
SIMPLE_DECL_ATTR(_staticInitializeObjCMetadata, StaticInitializeObjCMetadata,
281-
OnClass | NotSerialized | LongAttribute | UserInaccessible,
281+
OnClass | NotSerialized | LongAttribute | RejectByParser,
282282
/*Not serialized */ 69)
283283

284284
SIMPLE_DECL_ATTR(NSKeyedArchiveSubclassesOnly,

test/decl/protocol/conforms/nscoding.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ extension CodingB {
139139
// Inference of @_staticInitializeObjCMetadata.
140140
class SubclassOfCodingE : CodingE<Int> { }
141141

142+
// But don't allow one to write @_staticInitializeObjCMetadata!
143+
@_staticInitializeObjCMetadata // expected-error{{unknown attribute '_staticInitializeObjCMetadata'}}
144+
class DontAllowStaticInits { }
145+
142146
// CHECK-NOT: class_decl "CodingA"{{.*}}@_staticInitializeObjCMetadata
143147
// CHECK: class_decl "NestedA"{{.*}}@_staticInitializeObjCMetadata
144148
// CHECK: class_decl "NestedC"{{.*}}@_staticInitializeObjCMetadata

0 commit comments

Comments
 (0)