Skip to content

Commit d298602

Browse files
committed
[NFC] CoroutineAccessors: Delete TODO.
Add a test case.
1 parent f472d99 commit d298602

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,6 @@ bool AbstractStorageDecl::requiresCorrespondingUnderscoredCoroutineAccessor(
26872687

26882688
// The non-underscored accessor is not present, the underscored accessor
26892689
// won't be either.
2690-
// TODO: CoroutineAccessors: What if only the underscored is written out?
26912690
auto *accessor = decl ? decl : getOpaqueAccessor(kind);
26922691
if (!accessor)
26932692
return false;

test/SILGen/coroutine_accessors.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,52 @@ mutating func update(irm newValue: Int) throws -> Int {
160160
try coroutine_accessors.update(at: &irm, to: newValue)
161161
}
162162

163+
public var i_r_m: Int {
164+
// CHECK-LABEL: sil{{.*}} [ossa] @$s19coroutine_accessors1SV5i_r_mSivr :
165+
// CHECK-SAME: $@yield_once
166+
// CHECK-SAME: @convention(method)
167+
// CHECK-SAME: (@guaranteed S)
168+
// CHECK-SAME: ->
169+
// CHECK-SAME: @yields Int
170+
// CHECK-SAME: {
171+
// CHECK: } // end sil function '$s19coroutine_accessors1SV5i_r_mSivr'
172+
173+
_read {
174+
yield _i
175+
}
176+
// CHECK-NOT: sil [ossa] @$s19coroutine_accessors1SV5i_r_mSivx :
177+
// CHECK-LABEL: sil {{.*}}[ossa] @$s19coroutine_accessors1SV5i_r_mSivM :
178+
// CHECK-SAME: $@yield_once
179+
// CHECK-SAME: @convention(method)
180+
// CHECK-SAME: (@inout S)
181+
// CHECK-SAME: ->
182+
// CHECK-SAME: @yields @inout Int
183+
// CHECK-SAME: {
184+
// CHECK: } // end sil function '$s19coroutine_accessors1SV5i_r_mSivM'
185+
_modify {
186+
yield &_i
187+
}
188+
// CHECK-LABEL: sil {{.*}}[ossa] @$s19coroutine_accessors1SV5i_r_mSivs :
189+
// CHECK-SAME: $@convention(method)
190+
// CHECK-SAME: (Int, @inout S)
191+
// CHECK-SAME: ->
192+
// CHECK-SAME: ()
193+
// CHECK-SAME: {
194+
// CHECK: bb0(
195+
// CHECK-SAME: [[NEW_VALUE:%[^,]+]] :
196+
// CHECK-SAME: [[SELF:%[^,]+]] :
197+
// CHECK-SAME: ):
198+
// CHECK: [[SELF_ACCESS:%[^,]+]] = begin_access [modify] [unknown] [[SELF]]
199+
// CHECK: [[MODIFY_ACCESSOR:%[^,]+]] = function_ref @$s19coroutine_accessors1SV5i_r_mSivM
200+
// CHECK: ([[VALUE_ADDRESS:%[^,]+]],
201+
// CHECK-SAME: [[TOKEN:%[^)]+]])
202+
// CHECK-SAME: = begin_apply [[MODIFY_ACCESSOR]]([[SELF_ACCESS]])
203+
// CHECK: assign [[NEW_VALUE:%[^,]+]] to [[VALUE_ADDRESS]]
204+
// CHECK: end_apply [[TOKEN]]
205+
// CHECK: end_access [[SELF_ACCESS]]
206+
// CHECK-LABEL:} // end sil function '$s19coroutine_accessors1SV5i_r_mSivs'
207+
} // public var irm
208+
163209
} // public struct S
164210

165211
enum E : Error {

0 commit comments

Comments
 (0)