I might be missing the obvious here, but what's the context - I'm also not familiar with a bystander module, but I don't know where the term is coming from either.
A cross-import overlay module wraps its declaring module , re-exporting the declaring module’s contents but also adding extra APIs to it. The compiler imports the cross-import overlay module in place of the declaring module only when an additional bystanding module is imported into the same file.
I believe those happen not only for "bystander modules" (I have no experience with cross-import overlays) but also for extensions of symbols from other modules.
So if I had a module X with the following content:
extension String {
func foo() { }
}
then swift-symbolgraph-extract would emit an X@Swift.symbols.json file with just that symbol in it. And that symbol wouldn't be in X.symbols.json. At least that's what I've observed with my own modules. The code for that seems to be here.
That's right. Symbol graph information for APIs in extensions to types that are declared outside the defining module is emitted in separate symbol graph files. The format is ModuleName@ExtendedModule.symbols.json.
Only if that file came from extensions, instead of a cross-import overlay. A cross-import overlay will have an @ in its filename, but it won't populate swiftExtension unless the symbol itself was written as an extension. In that case, the module information will have bystander-module information instead.
(Small detail: this can get complicated if that overlay itself defines extensions to modules outside either itself or the declaring module, since then you'll get a mouthful like _DeclaringModule_BystanderModule@ExtendedModule.symbols.json! Those will populate swiftExtension.)
Because cross-import overlays are themselves a separate module, but treated as part of the declaring module, it's a bit more complicated than that. To fit in with existing tooling that looked for extension symbols alongside the symbols for the module being extended, you won't actually see _DeclaringModule_BystanderModule.symbols.json by itself.
So, to build up in reverse order:
Symbols in DeclaringModule@ExtendedModule.symbols.json:
Were all originally written in DeclaringModule
Are all namespaced to ExtendedModule (as they only affect symbols originally from ExtendedModule)
All contain a swiftExtension field pointing to ExtendedModule
Symbols in the overlay module_DeclaringModule_BystanderModule:
Will appear in the file _DeclaringModule_BystanderModule@DeclaringModule.symbols.json by defualt
Are namespaced to DeclaringModule by default
Only appear to a dependency when it imports bothDeclaringModule and BystanderModule in its code
Symbols in the file_DeclaringModule_BystanderModule@DeclaringModule.symbols.json:
Were originally written in the overlay module _DeclaringModule_BystanderModule
Are all namespaced to DeclaringModule
May contain a swiftExtension field pointing to ExtendedModule
...if the overlay applied an protocol to a type in ExtendedModule
Symbols with swiftExtension are symbols being added to a type in ExtendedModule by a protocol
Only appear to a dependency when it imports bothDeclaringModule and BystanderModule in its code
Symbols in the file _DeclaringModule_BystanderModule@ExtendedModule.symbols.json:
Were originally written in the overlay module _DeclaringModule_BystanderModule
Are all namespaced to ExtendedModule
All contain a swiftExtension field pointing to ExtendedModule
Only appear to a dependency when it imports all ofDeclaringModule, BystanderModule, andExtendedModule (so it can use the symbol being extended)
A cross-import overlay module wraps its declaring module , re-exporting the declaring module’s contents but also adding extra APIs to it. The compiler imports the cross-import overlay module in place of the declaring module only when an additional bystanding module is imported into the same file.
The point of a cross-import overlay is to sneak some extra APIs into the declaring module when the bystander module is also imported, without requiring that the declaring module use the bystander as a dependency. That's the difference: The declaring module is what's being extended, and the bystander is along for the ride.
This is a special case for cross-import overlays, since they are considered to extend the declaring module.
My mistake; they are namespaced to ExtendedModule.
why would they appear in _DeclaringModule_BystanderModule@DeclaringModule.symbols.json and not _DeclaringModule_BystanderModule@ExtendedModule.symbols.json?
Ah, now i see what you're pointing at. It looks like i mistyped the original post. It should read something like this (edits in bold):
There is no ExtendedModule in this scenario, since as you pointed out, otherwise it would be in _DeclaringModule_BystanderModule@ExtendedModule.symbols.json. The symbols are all namespaced to DeclaringModule, whether they're being added in the cross-import overlay or extending a symbol originally declared in DeclaringModule.