Skip to content

Commit e09e8c3

Browse files
committed
[Diagnostics] NFC: Adjust diagnostics improved by extraneous arguments fix
1 parent 1022ac7 commit e09e8c3

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

test/Constraints/closures.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func simplified1069() {
304304
// Make sure we cannot infer an () argument from an empty parameter list.
305305
func acceptNothingToInt (_: () -> Int) {}
306306
func testAcceptNothingToInt(ac1: @autoclosure () -> Int) {
307-
acceptNothingToInt({ac1($0)})
307+
acceptNothingToInt({ac1($0)}) // expected-error@:27 {{argument passed to call that takes no arguments}}
308308
// expected-error@-1{{contextual closure type '() -> Int' expects 0 arguments, but 1 was used in closure body}}
309309
}
310310

@@ -372,6 +372,7 @@ func rdar21078316() {
372372
var foo : [String : String]?
373373
var bar : [(String, String)]?
374374
bar = foo.map { ($0, $1) } // expected-error {{contextual closure type '([String : String]) throws -> [(String, String)]' expects 1 argument, but 2 were used in closure body}}
375+
// expected-error@-1:19 {{cannot convert value of type '([String : String], Any)' to closure result type '[(String, String)]'}}
375376
}
376377

377378

test/Constraints/diagnostics.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ f1(
4646
)
4747

4848
// Tuple element unused.
49-
f0(i, i,
49+
f0(i, i, // expected-error@:7 {{cannot convert value of type 'Int' to expected argument type 'Float'}}
5050
i) // expected-error{{extra argument in call}}
5151

5252

@@ -431,11 +431,13 @@ CurriedClass.method1(c)()
431431
_ = CurriedClass.method1(c)
432432
CurriedClass.method1(c)(1) // expected-error {{argument passed to call that takes no arguments}}
433433
CurriedClass.method1(2.0)(1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'CurriedClass'}}
434+
// expected-error@-1:27 {{argument passed to call that takes no arguments}}
434435

435436
CurriedClass.method2(c)(32)(b: 1) // expected-error{{extraneous argument label 'b:' in call}}
436437
_ = CurriedClass.method2(c)
437438
_ = CurriedClass.method2(c)(32)
438439
_ = CurriedClass.method2(1,2) // expected-error {{extra argument in call}}
440+
// expected-error@-1 {{instance member 'method2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
439441
CurriedClass.method2(c)(1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
440442
// expected-error@-1 {{extraneous argument label 'b:' in call}}
441443
CurriedClass.method2(c)(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}

test/Constraints/enum_cases.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ let _ = arr.map(E.tuple) // expected-error {{cannot invoke 'map' with an argumen
2727

2828
let _ = arr.map(G_E<String>.foo) // Ok
2929
let _ = arr.map(G_E<String>.bar) // Ok
30-
let _ = arr.map(G_E<String>.two) // expected-error {{cannot invoke 'map' with an argument list of type '(@escaping (String, String) -> G_E<String>)'}}
31-
// expected-note@-1{{expected an argument list of type '((Self.Element) throws -> T)'}}
30+
let _ = arr.map(G_E<String>.two) // expected-error {{cannot convert value of type '(String, String) -> G_E<String>' to expected argument type '(String) throws -> G_E<String>'}}
3231
let _ = arr.map(G_E<Int>.tuple) // expected-error {{cannot invoke 'map' with an argument list of type '(@escaping ((x: Int, y: Int)) -> G_E<Int>)'}}
3332
// expected-note@-1{{expected an argument list of type '((Self.Element) throws -> T)'}}
3433

test/Constraints/tuple_arguments.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ func autoclosureSplat() {
17281728
// wrap the closure in a function conversion.
17291729

17301730
takeFn { (fn: @autoclosure () -> Int, x: Int) in }
1731-
// expected-error@-1 {{contextual closure type '(_) -> ()' expects 1 argument, but 2 were used in closure body}}
1731+
// expected-error@-1 {{contextual closure type '(@escaping () -> Int) -> ()' expects 1 argument, but 2 were used in closure body}}
17321732

17331733
takeFn { (fn: @autoclosure @escaping () -> Int) in }
17341734
// FIXME: It looks like matchFunctionTypes() does not check @autoclosure at all.
@@ -1737,7 +1737,7 @@ func autoclosureSplat() {
17371737
// instead of changing the test.
17381738

17391739
takeFn { (fn: @autoclosure @escaping () -> Int, x: Int) in }
1740-
// expected-error@-1 {{contextual closure type '(_) -> ()' expects 1 argument, but 2 were used in closure body}}
1740+
// expected-error@-1 {{contextual closure type '(@escaping () -> Int) -> ()' expects 1 argument, but 2 were used in closure body}}
17411741
}
17421742

17431743
func noescapeSplat() {

test/Sema/call_as_function_simple.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ struct SimpleCallable {
1111
let foo = SimpleCallable()
1212
_ = foo(1)
1313
_ = foo(foo(1))
14-
15-
// TODO(SR-11378): Improve this error to match the error using a direct `callAsFunction` member reference.
16-
// expected-error @+2 {{cannot call value of non-function type 'SimpleCallable'}}
17-
// expected-error @+1 {{cannot invoke 'foo' with an argument list of type '(Int, Int)'}}
18-
_ = foo(1, 1)
14+
_ = foo(1, 1) // expected-error@:12 {{extra argument in call}}
1915
// expected-error @+1 {{cannot convert value of type 'SimpleCallable' to specified type '(Float) -> Float'}}
2016
let _: (Float) -> Float = foo
2117

test/decl/var/property_wrappers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ struct MissingPropertyWrapperUnwrap {
11171117
}
11181118

11191119
struct InvalidPropertyDelegateUse {
1120-
@Foo var x: Int = 42 // expected-error {{cannot invoke initializer for ty}}
1121-
// expected-note@-1{{overloads for 'Foo<_>' exist with these partially matching paramet}}
1120+
// TODO(diagnostics): We need to a tailored diagnostic for extraneous arguments in property delegate initialization
1121+
@Foo var x: Int = 42 // expected-error@:21 {{argument passed to call that takes no arguments}}
11221122

11231123
func test() {
11241124
self.x.foo() // expected-error {{value of type 'Int' has no member 'foo'}}

test/stdlib/PrintDiagnostics.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ var stream = ""
55
print(3, &stream) // expected-error{{'&' used with non-inout argument of type 'Any'}}
66
debugPrint(3, &stream) // expected-error{{'&' used with non-inout argument of type 'Any'}}
77

8-
print(3, &stream, appendNewline: false) // expected-error {{cannot invoke 'print' with an argument list of type '(Int, inout String, appendNewline: Bool)'}}
9-
// expected-note@-1 {{overloads for 'print' exist with these partially matching parameter lists: (Any..., separator: String, terminator: String), (Any..., separator: String, terminator: String, to: inout Target)}}
8+
print(3, &stream, appendNewline: false) // expected-error {{extra argument 'appendNewline' in call}}
9+
// expected-error@-1:10 {{'&' used with non-inout argument of type 'Any'}}
1010

11-
debugPrint(3, &stream, appendNewline: false) // expected-error {{cannot invoke 'debugPrint' with an argument list of type '(Int, inout String, appendNewline: Bool)'}}
12-
// expected-note@-1 {{verloads for 'debugPrint' exist with these partially matching parameter lists: (Any..., separator: String, terminator: String), (Any..., separator: String, terminator: String, to: inout Target)}}
11+
debugPrint(3, &stream, appendNewline: false) // expected-error {{extra argument 'appendNewline' in call}}
12+
// expected-error@-1:15 {{'&' used with non-inout argument of type 'Any'}}
1313

14-
print(4, quack: 5) // expected-error {{cannot invoke 'print' with an argument list of type '(Int, quack: Int)'}}
15-
// expected-note@-1 {{overloads for 'print' exist with these partially matching parameter lists: (Any..., separator: String, terminator: String), (Any..., separator: String, terminator: String, to: inout Target)}}
14+
print(4, quack: 5) // expected-error {{extra argument 'quack' in call}}

0 commit comments

Comments
 (0)