Skip to content

Commit 70b7c54

Browse files
committed
runtime: restore some typechecking for keypath functions
This addresses some feedback on #78141 as per @rjmccall. Ensure that the runtime functions match the expected signature.
1 parent 9907afa commit 70b7c54

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

stdlib/public/runtime/KeyPaths.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,24 @@ swift::swift_modifyAtReferenceWritableKeyPath(YieldOnceBuffer *buffer,
172172
&_release_owner_continuation, buffer),
173173
addrAndOwner.Addr };
174174
}
175+
176+
namespace {
177+
template <typename>
178+
struct YieldOnceCoroutine;
179+
180+
/// A template which generates the type of the ramp function of a yield-once
181+
/// coroutine.
182+
template <typename ResultType, typename... ArgumentTypes>
183+
struct YieldOnceCoroutine<ResultType(ArgumentTypes...)> {
184+
using type =
185+
SWIFT_CC(swift) YieldOnceResult<ResultType>(YieldOnceBuffer *,
186+
ArgumentTypes...);
187+
};
188+
189+
static_assert(std::is_same_v<decltype(swift_readAtKeyPath),
190+
YieldOnceCoroutine<const OpaqueValue * (const OpaqueValue *, void *)>::type>);
191+
static_assert(std::is_same_v<decltype(swift_modifyAtWritableKeyPath),
192+
YieldOnceCoroutine<OpaqueValue * (OpaqueValue *, void *)>::type>);
193+
static_assert(std::is_same_v<decltype(swift_modifyAtReferenceWritableKeyPath),
194+
YieldOnceCoroutine<OpaqueValue * (const OpaqueValue *, void *)>::type>);
195+
}

0 commit comments

Comments
 (0)