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
CCRefrigeratorCreateIndirect(fridge) // expected-error {{cannot convert value of type 'CCRefrigerator?' to expected argument type 'UnsafeMutablePointer<CCRefrigerator?>?'}}
121
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('CCRefrigerator' and 'UnsafeMutablePointer<CCRefrigerator?>') are expected to be equal}}
// expected-error@-1:34 {{cannot convert value of type 'Int' to expected argument type 'CCRefrigerator'}}
130
131
// expected-error@-2:40 {{cannot convert value of type 'CCItem?' to expected argument type 'UnsafeMutablePointer<Unmanaged<CCItem>?>?'}}
132
+
// expected-note@-3 {{arguments to generic parameter 'Wrapped' ('CCItem' and 'UnsafeMutablePointer<Unmanaged<CCItem>?>') are expected to be equal}}
131
133
}
132
134
133
135
func nameCollisions(){
134
136
varobjc:MyProblematicObject?
135
137
varcf:MyProblematicObjectRef?
136
138
cf = objc // expected-error {{cannot assign value of type 'MyProblematicObject?' to type 'MyProblematicObjectRef?'}}
139
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObject' and 'MyProblematicObjectRef') are expected to be equal}}
137
140
objc = cf // expected-error {{cannot assign value of type 'MyProblematicObjectRef?' to type 'MyProblematicObject?'}}
141
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicObjectRef' and 'MyProblematicObject') are expected to be equal}}
138
142
139
143
varcfAlias:MyProblematicAliasRef?
140
144
cfAlias = cf // okay
141
145
cf = cfAlias // okay
142
146
143
147
varotherAlias:MyProblematicAlias?
144
148
otherAlias = cfAlias // expected-error {{cannot assign value of type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>') to type 'MyProblematicAlias?' (aka 'Optional<Float>')}}
149
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAliasRef' (aka 'MyProblematicObjectRef') and 'MyProblematicAlias' (aka 'Float')) are expected to be equal}}
145
150
cfAlias = otherAlias // expected-error {{cannot assign value of type 'MyProblematicAlias?' (aka 'Optional<Float>') to type 'MyProblematicAliasRef?' (aka 'Optional<MyProblematicObjectRef>')}}
151
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('MyProblematicAlias' (aka 'Float') and 'MyProblematicAliasRef' (aka 'MyProblematicObjectRef')) are expected to be equal}}
Copy file name to clipboardExpand all lines: test/ClangImporter/ctypes_parse.swift
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -214,6 +214,7 @@ func testFunctionPointers() {
214
214
215
215
useFunctionPointer2(anotherFP)
216
216
sizedFP = fp // expected-error {{cannot assign value of type 'fptr?' (aka 'Optional<@convention(c) (Int32) -> Int32>') to type '(@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void)?'}}
217
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('fptr' (aka '@convention(c) (Int32) -> Int32') and '@convention(c) (CInt, CInt, UnsafeMutableRawPointer?) -> Void'}}
_ = optional as ${Type}? // expected-error{{is not convertible to}} expected-note {{use 'as!'}}
65
+
_ = optional as ${Type}? // expected-error{{cannot convert value of type '${ObjectType}?' to type '${Type}?' in coercion}} expected-note {{arguments to generic parameter 'Wrapped' ('${ObjectType}' and '${Type}') are expected to be equal}}
// expected-error@-1 {{cannot convert value of type 'NSString?' to expected argument type 'String?'}} {{21-21= as String?}}
301
305
vars2= ns ??"str"asStringasString // expected-error {{binary operator '??' cannot be applied to operands of type 'NSString?' and 'String'}}
302
306
303
-
lets3:NSString?="str"asString? // expected-error {{cannot convert value of type 'String?' to specified type 'NSString?'}}{{39-39= as NSString?}}
307
+
lets3:NSString?="str"asString? // expected-error {{cannot assign value of type 'String?' to type 'NSString?'}}{{39-39= as NSString?}}
308
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('String' and 'NSString') are expected to be equal}}
304
309
305
310
vars4:String= ns ??"str" // expected-error{{'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert?}} {{20-20=(}} {{31-31=) as String}}
306
311
vars5:String=(ns ??"str")asString // fixed version
307
312
}
308
313
309
314
// Make sure more complicated cast has correct parenthesization
310
315
func castMoreComplicated(anInt:Int?){
311
-
let _:(NSObject&NSCopying)?= anInt // expected-error{{cannot convert value of type 'Int?' to specified type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
316
+
let _:(NSObject&NSCopying)?= anInt // expected-error{{cannot assign value of type 'Int?' to type '(any NSObject & NSCopying)?'}}{{41-41= as (any NSObject & NSCopying)?}}
317
+
// expected-note@-1 {{arguments to generic parameter 'Wrapped' ('Int' and 'any NSObject & NSCopying') are expected to be equal}}
Copy file name to clipboardExpand all lines: test/Constraints/fixes.swift
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -158,16 +158,14 @@ struct Q {
158
158
lets:String?
159
159
}
160
160
letq=Q(s:nil)
161
-
leta:Int?= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
162
-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
163
-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
164
-
letb:Int= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
161
+
leta:Int?= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
162
+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
163
+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
164
+
letb:Int= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{17-17=?}} expected-note {{force-unwrap using '!'}}{{17-17=!}}
165
165
// expected-error@-1 {{cannot convert value of type 'String.UTF8View' to specified type 'Int'}}
166
-
// expected-note@-2{{chain the optional using '?'}}{{17-17=?}}
167
-
// expected-note@-3{{force-unwrap using '!'}}{{17-17=!}}
168
-
letd:Int!= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
169
-
// expected-error@-1 {{cannot convert value of type 'String.UTF8View?' to specified type 'Int?'}}
170
-
// expected-note@-2{{chain the optional using '?'}}{{18-18=?}}
166
+
letd:Int!= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}} expected-note {{chain the optional using '?'}}{{18-18=?}}
167
+
// expected-error@-1 {{cannot assign value of type 'String.UTF8View?' to type 'Int?'}}
168
+
// expected-note@-2 {{arguments to generic parameter 'Wrapped' ('String.UTF8View' and 'Int') are expected to be equal}}
171
169
letc= q.s.utf8 // expected-error{{value of optional type 'String?' must be unwrapped to refer to member 'utf8' of wrapped base type 'String'}}
172
170
// expected-note@-1{{chain the optional using '?' to access member 'utf8' only for non-'nil' base values}}{{12-12=?}}
173
171
// expected-note@-2{{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}{{12-12=!}}
0 commit comments