Skip to content

Commit 5fcb321

Browse files
authored
Merge pull request #72938 from tshortli/objc-async-conformance-type-conversion-tests
Tests: Increase test coverage in =objc_async_conformance.swift=
2 parents 179bc4b + 5bdd952 commit 5fcb321

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

test/ClangImporter/objc_async_conformance.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,33 @@ class C6: C5, ServiceProvider {
116116
extension ImplementsLoadable: @retroactive Loadable {
117117
public func loadStuff(withOtherIdentifier otherIdentifier: Int, reply: @escaping () -> Void) {}
118118
}
119+
120+
class ImplementsDictionaryLoader1: DictionaryLoader {
121+
func loadDictionary(completionHandler: @escaping ([String: NSNumber]?) -> Void) {}
122+
}
123+
124+
// expected-error@+1 {{type 'ImplementsDictionaryLoader2' does not conform to protocol 'DictionaryLoader'}}
125+
class ImplementsDictionaryLoader2: DictionaryLoader {
126+
func loadDictionary(completionHandler: @escaping ([String: Any]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : Any]?) -> Void) -> ()'}}
127+
}
128+
129+
// expected-error@+1 {{type 'ImplementsDictionaryLoader3' does not conform to protocol 'DictionaryLoader'}}
130+
class ImplementsDictionaryLoader3: DictionaryLoader {
131+
func loadDictionary(completionHandler: @escaping ([String: NSNumber?]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : NSNumber?]?) -> Void) -> ()'}}
132+
}
133+
134+
// expected-error@+1 {{type 'ImplementsDictionaryLoader4' does not conform to protocol 'DictionaryLoader'}}
135+
class ImplementsDictionaryLoader4: DictionaryLoader {
136+
func loadDictionary(completionHandler: @escaping ([String: Int]?) -> Void) {} // expected-note {{candidate has non-matching type '(@escaping ([String : Int]?) -> Void) -> ()'}}
137+
}
138+
139+
class ImplementsFloatLoader: FloatLoader {
140+
public func loadFloat(completionHandler: @escaping (Float) -> Void) {}
141+
}
142+
143+
class ImplementsFloatLoader2: FloatLoader {
144+
public func loadFloat(withCompletionHandler completionHandler: @escaping (Float) -> Void) {}
145+
// expected-warning@-1 {{instance method 'loadFloat(withCompletionHandler:)' nearly matches optional requirement 'loadFloat(completionHandler:)' of protocol 'FloatLoader'}}
146+
// expected-note@-2 {{rename to 'loadFloat(completionHandler:)' to satisfy this requirement}}
147+
// expected-note@-3 {{move 'loadFloat(withCompletionHandler:)' to an extension to silence this warning}}
148+
}

test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,4 +355,13 @@ MAIN_ACTOR
355355
- (void)loadStuffWithGroupID:(NSInteger)groupID reply:(void (^)())reply;
356356
@end
357357

358+
@protocol DictionaryLoader
359+
- (void)loadDictionaryWithCompletionHandler:(void (^)(NSDictionary <NSString *, NSNumber *> * _Nullable))completionHandler;
360+
@end
361+
362+
@protocol FloatLoader
363+
@optional
364+
- (void)loadFloatWithCompletionHandler:(void (^)(float))completionHandler;
365+
@end
366+
358367
#pragma clang assume_nonnull end

0 commit comments

Comments
 (0)