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
Copy file name to clipboardExpand all lines: validation-test/Sema/type_checker_crashers_fixed/issue59294.swift
+77Lines changed: 77 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
// RUN: %target-typecheck-verify-swift
2
2
3
3
// https://github.com/apple/swift/issues/59294
4
+
// https://github.com/apple/swift/issues/59295
4
5
5
6
@propertyWrapper
6
7
structWrapperValue<Value>{
@@ -25,18 +26,94 @@ struct WrapperValue<Value> {
25
26
func printValue(){
26
27
print(value)
27
28
}
29
+
30
+
func returnValue()->Value{
31
+
return value
32
+
}
28
33
}
29
34
35
+
@propertyWrapper
36
+
structOuterWrapper<Value>{
37
+
varvalue:Value
38
+
init(wrappedValue:Value){
39
+
self.value = wrappedValue
40
+
}
41
+
42
+
varprojectedValue:Self{
43
+
returnself
44
+
}
45
+
46
+
varwrappedValue:Value{
47
+
get{
48
+
self.value
49
+
}
50
+
set{
51
+
self.value = newValue
52
+
}
53
+
}
54
+
}
30
55
31
56
classTest{
32
57
staticfunc test(){
33
58
return[0,1,2].compactMap{ _ in // expected-error {{unexpected non-void return value in void function}} expected-note {{did you mean to add a return type?}}
34
59
@WrapperValuevarvalue:Bool?=false
35
60
if value !=nil{
61
+
$value.printValue()
36
62
returnfalse
37
63
}
38
64
39
65
return value ??false
40
66
}
41
67
}
68
+
staticfunc testProjectedAndWrapperVars(){
69
+
func test(_:(Int)->Bool){}
70
+
func test(_:(String)->Void){}
71
+
72
+
test{
73
+
@WrapperValuevarvalue= $0
74
+
if $value.returnValue()>0{
75
+
test{
76
+
return $value.returnValue()== $0 &&
77
+
_value == $0
78
+
}
79
+
}
80
+
returnfalse
81
+
}
82
+
83
+
test{
84
+
@WrapperValuevarvalue= $0
85
+
86
+
test{
87
+
if _value != $0 { // Ok
88
+
$value.printValue()
89
+
}
90
+
}
91
+
}
92
+
}
93
+
94
+
staticfunc testNestedWrappers(){
95
+
func test(_:(Bool)->Void){}
96
+
func test(_:()->Void){}
97
+
98
+
test{
99
+
iftrue{
100
+
@OuterWrapper@WrapperValuevarvalue= $0
101
+
iftrue{
102
+
let _:Bool= _value == $0
103
+
let _:OuterWrapper<WrapperValue<Bool>>= $value
104
+
let _:Bool= value
105
+
}
106
+
}
107
+
}
108
+
}
109
+
110
+
staticfunc invalidVar(){
111
+
_ =[0,1,2].compactMap{
112
+
@WrapperValuevarvalue:Bool?= $0
113
+
// expected-error@-1 {{cannot convert value of type 'Int' to specified type 'Bool?'}}
0 commit comments