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
[Diagnostics] Move fix creation of AllowAutoClosurePointerConversion from
`matchTypes` to `repairFailures`.
This change handles invalid inout-to-pointer, array-to-pointer, and string-
to-pointer autoclosure conversions in the same way.
Copy file name to clipboardExpand all lines: test/Constraints/invalid_implicit_conversions.swift
+8-12Lines changed: 8 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ func test(
14
14
){
15
15
vari:Int=0
16
16
vara:[Int]=[0]
17
+
varb:[Int]?=[0]
17
18
lets="string"
18
19
19
20
takesAutoclosure(rawPtr,&i) // expected-error {{cannot perform pointer conversion of value of type 'Int' to autoclosure result type 'UnsafeRawPointer'}}
@@ -26,17 +27,12 @@ func test(
26
27
takesAutoclosure(ptr,&a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafePointer<Int>'}}
27
28
takesAutoclosure(optPtr,&i) // expected-error {{cannot perform pointer conversion of value of type 'Int' to autoclosure result type 'UnsafePointer<Int>?'}}
28
29
29
-
takesAutoclosure(rawPtr, a) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafeRawPointer, [Int])'}}
30
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
31
-
takesAutoclosure(ptr, a) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafePointer<Int>, [Int])'}}
32
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
30
+
takesAutoclosure(rawPtr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafeRawPointer'}}
31
+
takesAutoclosure(ptr, a) // expected-error {{cannot perform pointer conversion of value of type '[Int]' to autoclosure result type 'UnsafePointer<Int>'}}
32
+
takesAutoclosure(optPtr, b) // expected-error {{cannot perform pointer conversion of value of type '[Int]?' to autoclosure result type 'UnsafePointer<Int>?'}}
33
33
34
-
takesAutoclosure(rawPtr, s) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafeRawPointer, String)'}}
35
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
36
-
takesAutoclosure(ptrI8, s) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafePointer<Int8>, String)'}}
37
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
38
-
takesAutoclosure(ptrU8, s) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafePointer<UInt8>, String)'}}
39
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
40
-
takesAutoclosure(ptrVoid, s) // expected-error {{cannot invoke 'takesAutoclosure' with an argument list of type '(UnsafePointer<Void>, String)'}}
41
-
// expected-note@-1 {{expected an argument list of type '(T, @autoclosure () throws -> T)'}}
34
+
takesAutoclosure(rawPtr, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafeRawPointer'}}
35
+
takesAutoclosure(ptrI8, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafePointer<Int8>'}}
36
+
takesAutoclosure(ptrU8, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafePointer<UInt8>'}}
37
+
takesAutoclosure(ptrVoid, s) // expected-error {{cannot perform pointer conversion of value of type 'String' to autoclosure result type 'UnsafePointer<Void>'}}
0 commit comments