mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ModuleInterface] Intro export-as for Swift modules
Introduce a new flag `-export-as` to specify a name used to identify the target module in swiftinterfaces. This provides an analoguous feature for Swift module as Clang's `export_as` feature. In practice it should be used when a lower level module `MyKitCore` is desired to be shown publicly as a downstream module `MyKit`. This should be used in conjunction with `@_exported import MyKitCore` from `MyKit` that allows clients to refer to all services as being part of `MyKit`, while the new `-export-as MyKit` from `MyKitCore` will ensure that the clients swiftinterfaces also use the `MyKit` name for all services. In the current implementation, the export-as name is used in the module's clients and not in the declarer's swiftinterface (e.g. `MyKitCore`'s swiftinterface still uses the `MyKitCore` module name). This way the module swiftinterface can be verified. In the future, we may want a similar behavior for other modules in between `MyKitCore` and `MyKit` as verifying a swiftinterface referencing `MyKit` without it being imported would fail. rdar://103888618
This commit is contained in:
@@ -1324,3 +1324,10 @@ StringRef SerializedASTFile::getModuleDefiningPath() const {
|
||||
|
||||
return moduleFilename;
|
||||
}
|
||||
|
||||
StringRef SerializedASTFile::getExportedModuleName() const {
|
||||
auto name = File.getModuleExportAsName();
|
||||
if (!name.empty())
|
||||
return name;
|
||||
return FileUnit::getExportedModuleName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user