File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,8 @@ BoxPair::Return SWIFT_RT_ENTRY_IMPL(swift_allocBox)(const Metadata *type) {
248
248
249
249
void swift::swift_deallocBox (HeapObject *o) {
250
250
auto metadata = static_cast <const GenericBoxHeapMetadata *>(o->metadata );
251
+ // Move the object to the deallocating state (+1 -> +0).
252
+ o->refCounts .decrementFromOneNonAtomic ();
251
253
SWIFT_RT_ENTRY_CALL (swift_deallocObject)(o, metadata->getAllocSize (),
252
254
metadata->getAllocAlignMask ());
253
255
}
Original file line number Diff line number Diff line change @@ -48,3 +48,37 @@ map({()})
48
48
49
49
map ( { ( x: Int ) -> Int in x} )
50
50
// CHECK: Non-void overload
51
+
52
+ // This used to assert in runtime assert builds.
53
+ protocol Initializable {
54
+ init ( )
55
+ }
56
+
57
+ func f2< T: Initializable > ( _ x: T ) -> T ? { return nil }
58
+
59
+ func c< T: Initializable > ( _ x: T ) {
60
+
61
+ ( {
62
+ guard var b = f2 ( x) else { print ( " success " ) ; return }
63
+ let c = { b = T ( ) }
64
+ _ = ( b, c)
65
+ } ) ( )
66
+
67
+ }
68
+ extension Bool : Initializable {
69
+ init ( ) {
70
+ self = true
71
+ }
72
+ }
73
+ // CHECK: success
74
+ c ( true )
75
+
76
+
77
+ func f( ) -> Bool ? { return nil }
78
+
79
+ // CHECK: success
80
+ ( {
81
+ guard var b = f ( ) else { print ( " success " ) ; return }
82
+ let c = { b = true }
83
+ _ = ( b, c)
84
+ } ) ( )
You can’t perform that action at this time.
0 commit comments