mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When the Clang importer imports the components of a C function pointer type, it generally translates foreign types into their native equivalents, just for the convenience of Swift code working with those functions. However, this translation must be unambiguously reversible, so (among other things) it cannot do this when the native type is also a valid foreign type. Specifically, this means that the Clang importer cannot import ObjCBool as Swift.Bool in these positions because Swift.Bool corresponds directly to the C type _Bool. SIL type lowering manually reverses the type-import process using a combination of duplicated logic and an abstraction pattern which includes information about the original Clang type that was imported. This abstraction pattern is generally able to tell SIL type lowering exactly what type to reverse to. However, @convention(c) function types may appear in positions from which it is impossible to recover the original Clang function type; therefore the reversal must be faithful to the proper rules. To do this we must propagate bridgeability just as the imported would. This reversal system is absolutely crazy, and we should really just - record an unbridged function type for imported declarations and - record an unbridged function type and Clang function type for @convention (c) function types whenever we create them. But for now, it's what we've got. rdar://43656704
25 KiB
25 KiB