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
[Property Wrappers] Type check out-of-line initialized property wrappers
via SolutionApplicationTarget. This allows fixes to be applied and diagnosed
for better error messages in the case of failures, and removes code
duplication for generating property wrapper constraints.
vary:NotHashable // expected-error{{property type 'NotHashable' does not match that of the 'wrappedValue' property of its wrapper type 'WrapperForHashable'}}
322
+
@WrapperForHashable // expected-error {{generic struct 'WrapperForHashable' requires that 'NotHashable' conform to 'Hashable'}}
323
+
vary:NotHashable
325
324
326
325
@WrapperForHashable
327
326
varyOkay:Int
328
327
329
328
@WrapperWithTwoParams
330
329
varzOkay:(Int,Float)
331
330
332
-
// FIXME: Need a better diagnostic here
333
-
@HasNestedWrapper.NestedWrapper
334
-
varw:Int // expected-error{{property type 'Int' does not match that of the 'wrappedValue' property of its wrapper type 'HasNestedWrapper.NestedWrapper'}}
331
+
@HasNestedWrapper.NestedWrapper // expected-error {{generic parameter 'T' could not be inferred}} expected-note {{explicitly specify}}
structFunction<T, U>{ // expected-note{{property wrapper type 'Function' declared here}}
342
+
structFunction<T, U>{ // expected-note{{'U' declared as parameter to type 'Function'}}
345
343
varwrappedValue:(T)->U?
346
344
}
347
345
348
346
structTestFunction{
349
347
@Functionvarf:(Int)->Float?
350
-
351
-
@Functionvarf2:(Int)->Float // expected-error{{property type '(Int) -> Float' does not match that of the 'wrappedValue' property of its wrapper type 'Function'}}
348
+
349
+
// FIXME: This diagnostic should be more specific
350
+
@Functionvarf2:(Int)->Float // expected-error{{generic parameter 'U' could not be inferred}}
351
+
// expected-note@-1 {{explicitly specify}}
352
352
353
353
func test(){
354
354
let _:Int= _f // expected-error{{cannot convert value of type 'Function<Int, Float>' to specified type 'Int'}}
structHasNestedWrapper<T>{ // expected-note {{'T' declared as parameter to type 'HasNestedWrapper'}}
362
362
@propertyWrapper
363
-
structNestedWrapper<U>{ // expected-note{{property wrapper type 'NestedWrapper' declared here}}
363
+
structNestedWrapper<U>{
364
364
varwrappedValue:U
365
365
init(wrappedValue initialValue:U){
366
366
self.wrappedValue = initialValue
@@ -1026,7 +1026,7 @@ struct WrapperB<Value> {
1026
1026
}
1027
1027
1028
1028
@propertyWrapper
1029
-
structWrapperC<Value>{
1029
+
structWrapperC<Value>{ // expected-note {{'Value' declared as parameter to type 'WrapperC'}}
1030
1030
varwrappedValue:Value?
1031
1031
1032
1032
init(wrappedValue initialValue:Value?){
@@ -1035,7 +1035,7 @@ struct WrapperC<Value> {
1035
1035
}
1036
1036
1037
1037
@propertyWrapper
1038
-
structWrapperD<Value, X, Y>{ // expected-note{{property wrapper type 'WrapperD' declared here}}
1038
+
structWrapperD<Value, X, Y>{
1039
1039
varwrappedValue:Value
1040
1040
}
1041
1041
@@ -1049,7 +1049,8 @@ struct TestComposition {
1049
1049
@WrapperA@WrapperB@WrapperCvarp2="Hello"
1050
1050
@WrapperD<WrapperE,Int,String>@WrapperEvarp3:Int?
1051
1051
@WrapperD<WrapperC,Int,String>@WrapperCvarp4:Int?
1052
-
@WrapperD<WrapperC,Int,String>@WrapperEvarp5:Int // expected-error{{property type 'Int' does not match that of the 'wrappedValue' property of its wrapper type 'WrapperD<WrapperC, Int, String>'}}
1052
+
@WrapperD<WrapperC,Int,String>@WrapperEvarp5:Int // expected-error{{generic parameter 'Value' could not be inferred}}
1053
+
// expected-note@-1 {{explicitly specify the generic arguments to fix this issue}}
1053
1054
1054
1055
func triggerErrors(d:Double){ // expected-note 6 {{mark method 'mutating' to make 'self' mutable}} {{2-2=mutating }}
1055
1056
p1 = d // expected-error{{cannot assign value of type 'Double' to type 'Int'}} {{8-8=Int(}} {{9-9=)}}
0 commit comments