Hi! I've stumbled upon Swift generated interface behavior that I don't understand, and I would appreciate any insights on this.
Let's say there's a couple of modules declared in a modulemap file like this:
module A {
header "a.h"
export *
}
module A2 {
header "a2.h"
export *
}
// a.h
typedef int MyInt;
MyInt a() { /* ... */ }
// a2.h
#include "a.h"
MyInt a2() { return a(); }
Generated SourceKit Swift interface for A2
starts with an import A
statement, which is exactly what I would expect.
However, if the modules are nested, the import statement is not there:
module mods {
module A {
header "a.h"
export *
}
module A2 {
header "a2.h"
export *
}
}
and the generated interface for mods.A2
only contains the func a2()
declaration, so the interface uses the MyInt
type which is not defined in it.
I have a couple of questions:
- Is this the expected behavior?
- Is there a way to make sure the import statement is generated even for the nested situation? Perhaps some modulemap keyword, or a SourceKit argument.
Thanks!