Skip to content

Commit 5b7fd8c

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[test] Updates diagnostic messages for existing tests
1 parent 76b8209 commit 5b7fd8c

File tree

6 files changed

+20
-11
lines changed

6 files changed

+20
-11
lines changed

test/ClangImporter/cfuncs_parse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func test_cfunc2(_ i: Int) {
1717

1818
func test_cfunc3_a() {
1919
let b = cfunc3( { (a : Double, b : Double) -> Double in a + b } )
20-
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped}}
20+
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'Optional<double_bin_op_block>' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped to a value of type 'double_bin_op_block' (aka '(Double, Double) -> Double')}}
2121
// expected-note@-1{{coalesce}}
2222
// expected-note@-2{{force-unwrap}}
2323
_ = b!(1.5, 2.5) as Double
@@ -26,7 +26,7 @@ func test_cfunc3_a() {
2626

2727
func test_cfunc3_b() {
2828
let b = cfunc3( { a, b in a + b } )
29-
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped}}
29+
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'Optional<double_bin_op_block>' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped to a value of type 'double_bin_op_block' (aka '(Double, Double) -> Double')}}
3030
// expected-note@-1{{coalesce}}
3131
// expected-note@-2{{force-unwrap}}
3232
_ = b!(1.5, 2.5) as Double
@@ -35,7 +35,7 @@ func test_cfunc3_b() {
3535

3636
func test_cfunc3_c() {
3737
let b = cfunc3({ $0 + $1 })
38-
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped}}
38+
_ = b(1.5, 2.5) as Double // expected-error{{value of optional type 'Optional<double_bin_op_block>' (aka 'Optional<(Double, Double) -> Double>') must be unwrapped to a value of type 'double_bin_op_block' (aka '(Double, Double) -> Double')}}
3939
// expected-note@-1{{coalesce}}
4040
// expected-note@-2{{force-unwrap}}
4141
_ = b!(1.5, 2.5) as Double

test/ClangImporter/objc_parse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ extension Wobbler2 : NSMaybeInitWobble { // expected-error{{type 'Wobbler2' does
290290

291291
func optionalMemberAccess(_ w: NSWobbling) {
292292
w.wobble()
293-
w.wibble() // expected-error{{value of optional type '(() -> Void)?' must be unwrapped}}
293+
w.wibble() // expected-error{{value of optional type 'Optional<() -> Void>' must be unwrapped to a value of type '() -> Void'}}
294294
// expected-note@-1{{coalesce}}
295295
// expected-note@-2{{force-unwrap}}
296296
let x = w[5]!!

test/Constraints/fixes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func extraCall() {
9393
var i = 7
9494
i = i() // expected-error{{cannot call value of non-function type 'Int'}}{{8-10=}}
9595

96-
maybeFn()(5) // expected-error{{value of optional type '((Int) -> Int)?' must be unwrapped to a value of type '(Int) -> Int'}}
96+
maybeFn()(5) // expected-error{{value of optional type 'Optional<((Int) -> Int)>' must be unwrapped to a value of type '(Int) -> Int'}}
9797
// expected-note@-1{{coalesce using '??' to provide a default when the optional value contains 'nil'}}
9898
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
9999
}

test/Constraints/patterns.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ switch staticMembers {
291291
case .init(0): break
292292
case .init(_): break // expected-error{{'_' can only appear in a pattern}}
293293
case .init(let x): break // expected-error{{cannot appear in an expression}}
294-
case .init(opt: 0): break // expected-error{{pattern cannot match values of type 'StaticMembers'}}
294+
case .init(opt: 0): break // expected-error{{value of optional type 'StaticMembers?' must be unwrapped to a value of type 'StaticMembers'}}
295+
// expected-note@-1{{coalesce}}
296+
// expected-note@-2{{force-unwrap}}
295297

296298
case .prop: break
297299
// TODO: repeated error message
@@ -308,7 +310,9 @@ switch staticMembers {
308310
case .method(withLabel: let x): break // expected-error{{cannot appear in an expression}}
309311

310312
case .optMethod: break // expected-error{{cannot match}}
311-
case .optMethod(0): break // expected-error{{pattern cannot match values of type 'StaticMembers'}}
313+
case .optMethod(0): break // expected-error{{value of optional type 'StaticMembers?' must be unwrapped to a value of type 'StaticMembers'}}
314+
// expected-note@-1{{coalesce}}
315+
// expected-note@-2{{force-unwrap}}
312316
}
313317

314318
_ = 0

test/expr/delayed-ident/static_var.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@ struct HasClosure {
4646
var _: HasClosure = .factoryNormal(0)
4747
var _: HasClosure = .factoryReturnOpt(1)!
4848
var _: HasClosure = .factoryIUO(2)
49-
var _: HasClosure = .factoryOpt(3) // expected-error {{static property 'factoryOpt' is not a function}}
49+
var _: HasClosure = .factoryOpt(3) // expected-error {{value of optional type 'Optional<((Int) -> HasClosure)>' must be unwrapped to a value of type '(Int) -> HasClosure'}}
50+
// expected-note@-1{{coalesce}}
51+
// expected-note@-2{{force-unwrap}}
5052
var _: HasClosure = .factoryOpt!(4) // expected-error {{type of expression is ambiguous without more context}}

test/expr/postfix/dot/optional_context_member.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ func nonOptContext() -> Foo {
1313
case ():
1414
return .someVar
1515
case (): // expected-warning {{case is already handled by previous patterns; consider removing it}}
16-
// FIXME: Customize this diagnostic for the optional case.
17-
return .someOptVar // expected-error 1 {{member 'someOptVar' in 'Foo' produces result of type 'Foo?', but context expects 'Foo'}}
16+
return .someOptVar // expected-error {{value of optional type 'Foo?' must be unwrapped to a value of type 'Foo'}}
17+
// expected-note@-1 {{coalesce}}
18+
// expected-note@-2 {{force-unwrap}}
1819
// TODO
1920
//case ():
2021
// return .someOptVar!
2122
case (): // expected-warning {{case is already handled by previous patterns; consider removing it}}
2223
return .someFunc()
2324
case (): // expected-warning {{case is already handled by previous patterns; consider removing it}}
24-
return .someOptFunc() // expected-error{{member 'someOptFunc' in 'Foo' produces result of type 'Foo?', but context expects 'Foo'}}
25+
return .someOptFunc() // expected-error {{value of optional type 'Foo?' must be unwrapped to a value of type 'Foo'}}
26+
// expected-note@-1 {{coalesce}}
27+
// expected-note@-2 {{force-unwrap}}
2528
// TODO
2629
//case ():
2730
// return .someOptFunc()!

0 commit comments

Comments
 (0)