Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/ClangImporter/objc_async_conformance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
9 changes: 9 additions & 0 deletions test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,13 @@ MAIN_ACTOR
- (void)loadStuffWithGroupID:(NSInteger)groupID reply:(void (^)())reply;
@end

@protocol DictionaryLoader
- (void)loadDictionaryWithCompletionHandler:(void (^)(NSDictionary <NSString *, NSNumber *> * _Nullable))completionHandler;
@end

@protocol FloatLoader
@optional
- (void)loadFloatWithCompletionHandler:(void (^)(float))completionHandler;
@end

#pragma clang assume_nonnull end