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
The code for checking conversions between function types is somewhat tricky. It's not immediately obvious what kinds of conversions are allowed, and what the different checks handle (leading to, for example, confusion as in https://bugs.swift.org/browse/SR-14050). We should document the allowed conversions and double-check that all of them have at least 1 test case.
The text was updated successfully, but these errors were encountered:
Posting some notes from a conversation with Slava:
converting from @convention(c) to a thick function should be fine, since you can allocate a context
it’s only conversions to @convention(c) that can’t work
unless the source is statically known, in which case we can emit a thunk that doesn’t capture context
Turns out, there is code which uses this in the stdlib.
So the checking for representation matching is not done entirely in CSSimplify's matchFunctionRepresentations, but part of it is done later during SILGen.
if (srcRepTy->getRepresentation() !=
FunctionTypeRepresentation::CFunctionPointer) {
// A "conversion" of a DeclRef a C function pointer is done by referencing// the thunk (or original C function) with the C calling convention.result = emitCFunctionPointer(SGF, e);
theindigamer (JIRA User) I remember from working on this is that because of variance and subtype relation in contravariant and covariant places conversions between diference conventions can cause some confusion. Perhaps this should be documented together as well =]
Additional Detail from JIRA
md5: e32be650ad46166f441bcda46ece65d4
relates to:
Issue Description:
The code for checking conversions between function types is somewhat tricky. It's not immediately obvious what kinds of conversions are allowed, and what the different checks handle (leading to, for example, confusion as in https://bugs.swift.org/browse/SR-14050). We should document the allowed conversions and double-check that all of them have at least 1 test case.
The text was updated successfully, but these errors were encountered: