You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[QoI] Improve diagnostics for type member names shadowing top-level functions
Consider expression with an implicit 'self.' reference:
extension Sequence {
func test() -> Int {
return max(1, 2)
}
}
We currently shadow names that appear in nested scopes, so the
top-level two-argument min()/max() functions are shadowed by the
versions of min()/max() in Sequence (which don’t take the same
number of arguments). This patch aims to improve situation on this
front and produce better diagnostics when that happens, hinting
the user about what went wrong and where matching function is
declared.
Resolves <rdar://problem/25341015>.
Copy file name to clipboardExpand all lines: test/Constraints/members.swift
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -590,3 +590,43 @@ do {
590
590
throwSR_2193_Error.Boom
591
591
}catchlet e as SR_2193_Error.Boom{ // expected-error {{enum element 'Boom' is not a member type of 'SR_2193_Error'}}
592
592
}
593
+
594
+
// rdar://problem/25341015
595
+
extensionSequence{
596
+
func r25341015_1()->Int{
597
+
returnmax(1,2) // expected-error {{use of 'max' refers to instance method 'max(by:)' rather than global function 'max' in module 'Swift'}} expected-note {{use 'Swift.' to reference the global function in module 'Swift'}}
baz(1,2) // expected-error {{use of 'baz' refers to instance method 'baz()' rather than static method 'baz' in class 'C_25341015'}} expected-note {{use 'C_25341015.' to reference the static method}}
foo(1, y:2) // expected-error {{use of 'foo' refers to instance method 'foo(z:)' rather than static method 'foo(_:y:)' in struct 'S_25341015'}} expected-note {{use 'S_25341015.' to reference the static method}}
615
+
}
616
+
}
617
+
618
+
func r25341015(){
619
+
func baz(_ x:Int, _ y:Int){}
620
+
classBar{
621
+
func baz(){}
622
+
func qux(){
623
+
baz(1,2) // expected-error {{argument passed to call that takes no arguments}}
624
+
}
625
+
}
626
+
}
627
+
628
+
func r25341015_local(x:Int, y:Int){}
629
+
func r25341015_inner(){
630
+
func r25341015_local(){}
631
+
r25341015_local(x:1, y:2) // expected-error {{argument passed to call that takes no arguments}}
0 commit comments