[SR-13032] Invalid .swiftinterface when textually including C struct in different modules #55477
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
c interop
Feature: Interoperability with C
compiler
The Swift compiler in itself
swift 5.3
textual interfaces
unexpected error
Bug: Unexpected error
Additional Detail from JIRA
md5: 13b4c87976347810d07df29fa015e2a2
Issue Description:
The following commit contains a failing test demonstrating the problem:
martinboehme@f431f1b
It generates a
.swiftinterface
for moduleMainModule
, but this.swiftinterface
then fails to compile with the error message:To summarize the situation:
SubModule
imports Clang modulesForeignA
andForeignB
. BothForeignA
andForeignB
include a textual header containing the structForeignStruct
.ForeignB
but notForeignA
.ForeignStruct
is therefore available to clients ofSubModule
; those clients can use it either using the unqualified nameForeignStruct
or the qualified nameForeignB.ForeignStruct
, but notForeignA.ForeignStruct
(becauseSubModule
doesn't re-exportForeignA
).MainModule
importsSubModule
and usesForeignStruct
in the signature offuncTakingForeignStruct
. WhenMainModule
is compiled to a.swiftinterface
file, that signature erroneously refers toForeignStruct
asForeignA.ForeignStruct
instead ofForeignB.ForeignStruct
. Because of this, the resulting.swiftinterface
file does not compile.I discovered this issue in the course of investigating a CI failure on #32404. The repro above corresponds to the situation in the failing test as follows:
SubModule
isGlibc
ForeignA
isSwiftOverlayShims
ForeignB
isSwiftGlibc
The textual header is
sys/time.h
, andForeignStruct
isstruct timeval
I believe this needs to be fixed in
TypePrinter::printModuleContext()
, but I'm not sure exactly how.The text was updated successfully, but these errors were encountered: