Skip to content

[cxx-import] a Swift module that imports a C++ module and forces the client to enable interop produces unclear diagnostic #65833

Closed
@hyp

Description

@hyp

Right now when a Swift module A enables interoperability and imports a C++ module cxxmod, and Swift module B that consumes it doesn't, the compiler will fail to compile B with the following error:

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cxxmod.h"
        ^
/Users/alex/i/swift/test/Interop/SwiftToCxx/cross-module-refs/Inputs/cxxmod.h:1:1: error: unknown type name 'class'; did you mean 'Class'?
class TestMough {
^
<unknown>:0: note: 'Class' declared here
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cxxmod.h"
        ^
/Users/alex/i/swift/test/Interop/SwiftToCxx/cross-module-refs/Inputs/cxxmod.h:1:16: error: expected ';' after top level declarator
class TestMough {
               ^
<unknown>:0: error: could not build Objective-C module 'cxxmod'

The diagnostic should be improved to be more clear that the client needs to enable interoperability.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++triage neededThis issue needs more specific labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions