diff --git a/test/ClangImporter/objc_async_conformance.swift b/test/ClangImporter/objc_async_conformance.swift index ff20f1b8971bb..e463a4b6cacea 100644 --- a/test/ClangImporter/objc_async_conformance.swift +++ b/test/ClangImporter/objc_async_conformance.swift @@ -116,3 +116,33 @@ class C6: C5, ServiceProvider { extension ImplementsLoadable: @retroactive Loadable { public func loadStuff(withOtherIdentifier otherIdentifier: Int, reply: @escaping () -> Void) {} } + +class ImplementsDictionaryLoader1: DictionaryLoader { + func loadDictionary(completionHandler: @escaping ([String: NSNumber]?) -> Void) {} +} + +// expected-error@+1 {{type 'ImplementsDictionaryLoader2' does not conform to protocol 'DictionaryLoader'}} +class ImplementsDictionaryLoader2: DictionaryLoader { + func loadDictionary(completionHandler: @escaping ([String: Any]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : Any]?) -> Void) -> ()'}} +} + +// expected-error@+1 {{type 'ImplementsDictionaryLoader3' does not conform to protocol 'DictionaryLoader'}} +class ImplementsDictionaryLoader3: DictionaryLoader { + func loadDictionary(completionHandler: @escaping ([String: NSNumber?]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : NSNumber?]?) -> Void) -> ()'}} +} + +// expected-error@+1 {{type 'ImplementsDictionaryLoader4' does not conform to protocol 'DictionaryLoader'}} +class ImplementsDictionaryLoader4: DictionaryLoader { + func loadDictionary(completionHandler: @escaping ([String: Int]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : Int]?) -> Void) -> ()'}} +} + +class ImplementsFloatLoader: FloatLoader { + public func loadFloat(completionHandler: @escaping (Float) -> Void) {} +} + +class ImplementsFloatLoader2: FloatLoader { + public func loadFloat(withCompletionHandler completionHandler: @escaping (Float) -> Void) {} + // expected-warning@-1 {{instance method 'loadFloat(withCompletionHandler:)' nearly matches optional requirement 'loadFloat(completionHandler:)' of protocol 'FloatLoader'}} + // expected-note@-2 {{rename to 'loadFloat(completionHandler:)' to satisfy this requirement}} + // expected-note@-3 {{move 'loadFloat(withCompletionHandler:)' to an extension to silence this warning}} +} diff --git a/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h b/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h index 1029b9072b655..0a85dbe69fcef 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h +++ b/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h @@ -355,4 +355,13 @@ MAIN_ACTOR - (void)loadStuffWithGroupID:(NSInteger)groupID reply:(void (^)())reply; @end +@protocol DictionaryLoader +- (void)loadDictionaryWithCompletionHandler:(void (^)(NSDictionary * _Nullable))completionHandler; +@end + +@protocol FloatLoader +@optional +- (void)loadFloatWithCompletionHandler:(void (^)(float))completionHandler; +@end + #pragma clang assume_nonnull end