From 8a27b681b0e8e0fc13fb9853051e17ecd8a986a3 Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Tue, 9 Apr 2024 13:12:04 -0700 Subject: [PATCH 1/2] Tests: Increase test coverage in objc_async_conformance.swift. Add regression tests for rdar://125935350. --- .../objc_async_conformance.swift | 19 +++++++++++++++++++ .../usr/include/ObjCConcurrency.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/test/ClangImporter/objc_async_conformance.swift b/test/ClangImporter/objc_async_conformance.swift index ff20f1b8971bb..11ead9a2fcf55 100644 --- a/test/ClangImporter/objc_async_conformance.swift +++ b/test/ClangImporter/objc_async_conformance.swift @@ -116,3 +116,22 @@ 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) -> ()'}} +} diff --git a/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h b/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h index 1029b9072b655..16ccf209e8208 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h +++ b/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h @@ -355,4 +355,8 @@ MAIN_ACTOR - (void)loadStuffWithGroupID:(NSInteger)groupID reply:(void (^)())reply; @end +@protocol DictionaryLoader +- (void)loadDictionaryWithCompletionHandler:(void (^)(NSDictionary * _Nullable))completionHandler; +@end + #pragma clang assume_nonnull end From 5bdd952792fc23ea790206a14c504437210f2e8b Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Tue, 9 Apr 2024 15:18:47 -0700 Subject: [PATCH 2/2] Tests: More test coverage in objc_async_conformance.swift Add regression tests for rdar://125945942. --- test/ClangImporter/objc_async_conformance.swift | 11 +++++++++++ .../clang-importer-sdk/usr/include/ObjCConcurrency.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/test/ClangImporter/objc_async_conformance.swift b/test/ClangImporter/objc_async_conformance.swift index 11ead9a2fcf55..e463a4b6cacea 100644 --- a/test/ClangImporter/objc_async_conformance.swift +++ b/test/ClangImporter/objc_async_conformance.swift @@ -135,3 +135,14 @@ class ImplementsDictionaryLoader3: 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 16ccf209e8208..0a85dbe69fcef 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h +++ b/test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h @@ -359,4 +359,9 @@ MAIN_ACTOR - (void)loadDictionaryWithCompletionHandler:(void (^)(NSDictionary * _Nullable))completionHandler; @end +@protocol FloatLoader +@optional +- (void)loadFloatWithCompletionHandler:(void (^)(float))completionHandler; +@end + #pragma clang assume_nonnull end