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
* [NFC] Add a getOptionalityDepth method to return the number of optionals a type has
* [NFC] Use getOptionalityDepth to remove existing code
* [AST] Add a new diagnostic note for suggesting optional chaining
* [CSDiagnostics] Tweak MissingOptionalUnwrapFailure to suggest using optional chaining on closure
* [Test] Add a couple of test cases for perform_optional_chain_on_closure
* [CSDiagnostics] Change DeclRefExpr casts to isa checks
* [AST] Update diagnostic phrasing
* [Sema] Use new diagnostic identifier and update comment
* [Test] Add a new test case for function type
* [Test] Update cfuncs_parse.swift tests to check for new diagnostic note
Copy file name to clipboardExpand all lines: test/ClangImporter/cfuncs_parse.swift
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -24,26 +24,29 @@ func test_cfunc2(_ i: Int) {
24
24
func test_cfunc3_a(){
25
25
letb=cfunc3({(a :Double, b :Double)->Doublein a + b })
26
26
_ =b(1.5,2.5)asDouble // expected-error{{value of optional type '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')}}
27
-
// expected-note@-1{{coalesce}}
28
-
// expected-note@-2{{force-unwrap}}
27
+
// expected-note@-1{{use optional chaining to call this value of function type when optional is non-'nil'}}
28
+
// expected-note@-2{{coalesce}}
29
+
// expected-note@-3{{force-unwrap}}
29
30
_ = b!(1.5,2.5)asDouble
30
31
_ = b asDouble// expected-error{{cannot convert value of type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') to type 'Double' in coercion}}
31
32
}
32
33
33
34
func test_cfunc3_b(){
34
35
letb=cfunc3({ a, b in a + b })
35
36
_ =b(1.5,2.5)asDouble // expected-error{{value of optional type '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')}}
36
-
// expected-note@-1{{coalesce}}
37
-
// expected-note@-2{{force-unwrap}}
37
+
// expected-note@-1{{use optional chaining to call this value of function type when optional is non-'nil'}}
38
+
// expected-note@-2{{coalesce}}
39
+
// expected-note@-3{{force-unwrap}}
38
40
_ = b!(1.5,2.5)asDouble
39
41
_ = b asDouble// expected-error{{cannot convert value of type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') to type 'Double' in coercion}}
40
42
}
41
43
42
44
func test_cfunc3_c(){
43
45
letb=cfunc3({ $0 + $1 })
44
46
_ =b(1.5,2.5)asDouble // expected-error{{value of optional type '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')}}
45
-
// expected-note@-1{{coalesce}}
46
-
// expected-note@-2{{force-unwrap}}
47
+
// expected-note@-1{{use optional chaining to call this value of function type when optional is non-'nil'}}
48
+
// expected-note@-2{{coalesce}}
49
+
// expected-note@-3{{force-unwrap}}
47
50
_ = b!(1.5,2.5)asDouble
48
51
_ = b asDouble// expected-error{{cannot convert value of type 'double_bin_op_block?' (aka 'Optional<(Double, Double) -> Double>') to type 'Double' in coercion}}
0 commit comments