File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3706,7 +3706,11 @@ static bool diagnoseAmbiguity(
3706
3706
})) {
3707
3707
// All fixes have to do with arguments, so let's show the parameter
3708
3708
// lists.
3709
- auto *fn = type->getAs <AnyFunctionType>();
3709
+ //
3710
+ // It's possible that function type is wrapped in an optional
3711
+ // if it's from `@objc optional` method, so we need to ignore that.
3712
+ auto *fn =
3713
+ type->lookThroughAllOptionalTypes ()->getAs <AnyFunctionType>();
3710
3714
assert (fn);
3711
3715
3712
3716
if (fn->getNumParams () == 1 ) {
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s
2
+ // REQUIRES: objc_interop
3
+
4
+ import Foundation
5
+
6
+ @objc protocol P {
7
+ @objc optional static func test( a: UnsafePointer < Int > , _: Int )
8
+ // expected-note@-1 {{candidate has partially matching parameter list (a: UnsafePointer<Int>, Int)}}
9
+ @objc optional static func test( b: [ Int ] , _: Int )
10
+ // expected-note@-1 {{candidate has partially matching parameter list (b: [Int], Int)}}
11
+ }
12
+
13
+ @objc class S : NSObject , P {
14
+ static func test( a: UnsafePointer < Int > , _: Int ) { }
15
+ static func test( b: [ Int ] , _: Int ) { }
16
+ }
17
+
18
+ func test( s: P . Type , v: Int ) {
19
+ _ = s. test!( c: v, 0 ) // expected-error {{no exact matches in call to static method 'test'}}
20
+ }
You can’t perform that action at this time.
0 commit comments