Skip to content

Conversation

@j-hui
Copy link
Contributor

@j-hui j-hui commented Oct 22, 2025

In C++, it is legal to have a typedef to an invalid type (e.g., a templated type that cannot be instantiated). We should not import these eagerly in Swift, because doing so causes spurious type errors that would not otherwise appear in C++---this is validated by the test that is added in this patch, which runs clang.

Instead, we can rely on these types being lazily imported on-demand, i.e., only when the type is referenced directly in Swift or indirectly by an imported decl that is used in Swift.

rdar://145238539

In C++, it is legal to have a typedef to an invalid type (e.g.,
a templated type that cannot be instantiated). We should not import
these eagerly in Swift, because doing so causes spurious type errors
that would not otherwise appear in C++---this is validated by the test
that is added in this patch, which runs clang.

Instead, we can rely on these types being lazily imported on-demand,
i.e., only when the type is referenced directly in Swift or indirectly
by an imported decl that is used in Swift.

rdar://145238539
@j-hui
Copy link
Contributor Author

j-hui commented Oct 22, 2025

@swift-ci please test

// CHECK-NEXT: typealias UsingBool = Bool
// CHECK-NEXT: }

//--- Inputs/CxxErrHeader.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still share the same header file, as long as you use different prefixes with -verify.

@Xazax-hun
Copy link
Contributor

@swift-ci please test macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants