mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In C interop mode, the return type of builtin functions like 'memcpy' from headers like 'string.h' drops any nullability specifiers from their return type, and preserves it on the declared return type. Thus, in C mode the imported return type of such functions is always optional. However, in C++ interop mode, the return type of builtin functions can preseve the nullability specifiers on their return type, and thus the imported return type of such functions can be non-optional, if the type is annotated with `_Nonnull`. The difference between these two modes can break cross-module Swift serialization, as Swift will no longer be able to resolve an x-ref such as 'memcpy' from a Swift module that uses C interop, within a Swift context that uses C++ interop. In order to avoid the x-ref resolution failure, normalize the return type's nullability for builtin functions in C++ interop mode, to match the imported type in C interop mode. This fixed an issue when using 'memcpy' from the Android NDK in a x-module context, like between Foundation (that inlines it) and another user module.
10 lines
150 B
Plaintext
10 lines
150 B
Plaintext
module DefaultArguments {
|
|
header "default-arguments.h"
|
|
export *
|
|
}
|
|
|
|
module CustomStringBuiltins {
|
|
header "custom-string-builtins.h"
|
|
export *
|
|
}
|