You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"'@objc' can only be applied to an extension of a class", ())
6101
6120
6102
6121
// If you change this, also change enum ObjCReason
6103
-
#defineOBJC_ATTR_SELECT"select{marked @_cdecl|marked dynamic|marked @objc|marked @objcMembers|marked @IBOutlet|marked @IBAction|marked @IBSegueAction|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override|an implementation of an @objc requirement|marked @IBInspectable|marked @GKInspectable|in an @objc extension of a class (without @nonobjc)|marked @objc by an access note}"
6122
+
#defineOBJC_ATTR_SELECT"select{marked @_cdecl|marked dynamic|marked @objc|marked @objcMembers|marked @IBOutlet|marked @IBAction|marked @IBSegueAction|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override|an implementation of an @objc requirement|marked @IBInspectable|marked @GKInspectable|in an @objc extension of a class (without @nonobjc)|in an @_objcImplementation extension of a class (without final or @nonobjc)|marked @objc by an access note}"
6104
6123
6105
6124
WARNING(attribute_meaningless_when_nonobjc,none,
6106
6125
"'@%0' attribute is meaningless on a property that cannot be "
Copy file name to clipboardExpand all lines: test/decl/ext/objc_implementation.swift
+35-3Lines changed: 35 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ protocol EmptySwiftProto {}
114
114
115
115
internalvarpropertyNotFromHeader1:CInt
116
116
// expected-warning@-1 {{property 'propertyNotFromHeader1' does not match any property declared in the headers for 'ObjCClass'; did you use the property's Swift name?; this will become an error before '@_objcImplementation' is stabilized}}
117
-
// expected-note@-2 {{add 'private' or 'fileprivate' to define an Objective-C-compatible property not declared in the header}} {{3-3=private}}
117
+
// expected-note@-2 {{add 'private' or 'fileprivate' to define an Objective-C-compatible property not declared in the header}} {{3-11=private}}
118
118
// expected-note@-3 {{add 'final' to define a Swift property that cannot be overridden}} {{3-3=final }}
119
119
120
120
@objcprivatevarpropertyNotFromHeader2:CInt
@@ -183,6 +183,38 @@ protocol EmptySwiftProto {}
183
183
classfunc instanceMethod2(_:CInt){
184
184
// expected-warning@-1 {{class method 'instanceMethod2' does not match instance method declared in header; this will become an error before '@_objcImplementation' is stabilized}} {{3-9=}}
185
185
}
186
+
187
+
publicinit(notFromHeader1:CInt){
188
+
// expected-warning@-1 {{initializer 'init(notFromHeader1:)' does not match any initializer declared in the headers for 'ObjCClass'; did you use the initializer's Swift name?}}
189
+
// expected-note@-2 {{add 'private' or 'fileprivate' to define an Objective-C-compatible initializer not declared in the header}} {{3-9=private}}
190
+
// expected-note@-3 {{add '@nonobjc' to define a Swift-only initializer}} {{3-3=@nonobjc }}
191
+
}
192
+
193
+
publicrequiredinit(notFromHeader2:CInt){
194
+
// expected-warning@-1 {{initializer 'init(notFromHeader2:)' does not match any initializer declared in the headers for 'ObjCClass'; did you use the initializer's Swift name?}}
195
+
// expected-note@-2 {{add 'private' or 'fileprivate' to define an Objective-C-compatible initializer not declared in the header}} {{3-9=private}}
196
+
// expected-note@-3 {{add '@nonobjc' to define a Swift-only initializer}} {{3-3=@nonobjc }}
197
+
}
198
+
199
+
publicconvenienceinit(notFromHeader3:CInt){
200
+
// expected-warning@-1 {{initializer 'init(notFromHeader3:)' does not match any initializer declared in the headers for 'ObjCClass'; did you use the initializer's Swift name?}}
201
+
// expected-note@-2 {{add 'private' or 'fileprivate' to define an Objective-C-compatible initializer not declared in the header}} {{3-9=private}}
202
+
// expected-note@-3 {{add '@nonobjc' to define a Swift-only initializer}} {{3-3=@nonobjc }}
203
+
}
204
+
205
+
@nonobjcpublicinit(notFromHeader4:CInt){
206
+
// expected-warning@-1 {{initializer 'init(notFromHeader4:)' is not valid in an '@_objcImplementation' extension because Objective-C subclasses must be able to override designated initializers}}
207
+
// expected-note@-2 {{add 'convenience' keyword to make this a convenience initializer}} {{12-12=convenience }}
208
+
}
209
+
210
+
@nonobjcpublicrequiredinit(notFromHeader5:CInt){
211
+
// expected-warning@-1 {{initializer 'init(notFromHeader5:)' is not valid in an '@_objcImplementation' extension because Objective-C subclasses must be able to override required initializers}}
212
+
// expected-note@-2 {{replace 'required' keyword with 'convenience' to make this a convenience initializer}} {{19-27=convenience}}
func nullableResult()->Any{fatalError()} // expected-warning {{instance method 'nullableResult()' of type '() -> Any' does not match type '() -> Any?' declared by the header}}
383
415
func nullableArgument(_:Any){} // expected-warning {{instance method 'nullableArgument' of type '(Any) -> ()' does not match type '(Any?) -> Void' declared by the header}}
384
416
385
-
func nonPointerResult()->CInt!{fatalError()} // expected-error{{method cannot be implicitly @objc because its result type cannot be represented in Objective-C}}
386
-
func nonPointerArgument(_:CInt!){} // expected-error {{method cannot be implicitly @objc because the type of the parameter cannot be represented in Objective-C}}
417
+
func nonPointerResult()->CInt!{fatalError()} // expected-error{{method cannot be in an @_objcImplementation extension of a class (without final or @nonobjc) because its result type cannot be represented in Objective-C}}
418
+
func nonPointerArgument(_:CInt!){} // expected-error {{method cannot be in an @_objcImplementation extension of a class (without final or @nonobjc) because the type of the parameter cannot be represented in Objective-C}}
0 commit comments