@@ -336,3 +336,51 @@ func testOverloadedWithUnavailable(ao: AnyObject) {
336
336
ao. overloadedWithUnavailableB ( )
337
337
}
338
338
339
+ // Test that we correctly diagnose ambiguity for different typed members available
340
+ // through dynamic lookup.
341
+ @objc protocol P3 {
342
+ var ambiguousProperty : String { get } // expected-note {{found this candidate}}
343
+ var unambiguousProperty : Int { get }
344
+
345
+ func ambiguousMethod( ) -> String // expected-note 2{{found this candidate}}
346
+ func unambiguousMethod( ) -> Int
347
+
348
+ func ambiguousMethodParam( _ x: String ) // expected-note {{found this candidate}}
349
+ func unambiguousMethodParam( _ x: Int )
350
+
351
+ subscript( ambiguousSubscript _: Int ) -> String { get } // expected-note {{found this candidate}}
352
+ subscript( unambiguousSubscript _: String ) -> Int { get } // expected-note {{found this candidate}}
353
+ }
354
+
355
+ class C1 {
356
+ @objc var ambiguousProperty : Int { return 0 } // expected-note {{found this candidate}}
357
+ @objc var unambiguousProperty : Int { return 0 }
358
+
359
+ @objc func ambiguousMethod( ) -> Int { return 0 } // expected-note 2{{found this candidate}}
360
+ @objc func unambiguousMethod( ) -> Int { return 0 }
361
+
362
+ @objc func ambiguousMethodParam( _ x: Int ) { } // expected-note {{found this candidate}}
363
+ @objc func unambiguousMethodParam( _ x: Int ) { }
364
+
365
+ @objc subscript( ambiguousSubscript _: Int ) -> Int { return 0 } // expected-note {{found this candidate}}
366
+ @objc subscript( unambiguousSubscript _: String ) -> Int { return 0 } // expected-note {{found this candidate}}
367
+ }
368
+
369
+ func testAnyObjectAmbiguity( _ x: AnyObject ) {
370
+ _ = x. ambiguousProperty // expected-error {{ambiguous use of 'ambiguousProperty'}}
371
+ _ = x. unambiguousProperty
372
+
373
+ _ = x. ambiguousMethod ( ) // expected-error {{ambiguous use of 'ambiguousMethod()'}}
374
+ _ = x. unambiguousMethod ( )
375
+
376
+ _ = x. ambiguousMethod // expected-error {{ambiguous use of 'ambiguousMethod()'}}
377
+ _ = x. unambiguousMethod
378
+
379
+ _ = x. ambiguousMethodParam // expected-error {{ambiguous use of 'ambiguousMethodParam'}}
380
+ _ = x. unambiguousMethodParam
381
+
382
+ _ = x [ ambiguousSubscript: 0 ] // expected-error {{ambiguous use of 'subscript(ambiguousSubscript:)'}}
383
+
384
+ // FIX-ME(SR-8611): This is currently ambiguous but shouldn't be.
385
+ _ = x [ unambiguousSubscript: " " ] // expected-error {{ambiguous use of 'subscript(unambiguousSubscript:)'}}
386
+ }
0 commit comments