@@ -2856,14 +2856,46 @@ namespace {
2856
2856
return nullptr ;
2857
2857
2858
2858
auto Loc = Impl.importSourceLoc (Decl->getLocation ());
2859
- auto Result = Impl.createDeclWithClangNode <TypeAliasDecl>(Decl,
2860
- AccessLevel::Public,
2861
- Impl.importSourceLoc (Decl->getBeginLoc ()),
2862
- SourceLoc (), Name,
2863
- Loc,
2864
- /* genericparams*/ nullptr , DC);
2865
-
2866
- Result->setUnderlyingType (SwiftType);
2859
+
2860
+ swift::Decl *Result = nullptr ;
2861
+ if (importer::isUnavailableInSwift (Decl, nullptr , true ) &&
2862
+ Impl.SwiftContext .LangOpts .EnableCXXInterop ) {
2863
+ ASTContext &ctx = Impl.SwiftContext ;
2864
+
2865
+ // Compute the underlying type.
2866
+ clang::QualType ClangType = Decl->getUnderlyingType ();
2867
+ auto underlyingType = Impl.importTypeIgnoreIUO (
2868
+ ClangType, ImportTypeKind::Enum,
2869
+ ImportDiagnosticAdder (Impl, Decl, Decl->getLocation ()),
2870
+ isInSystemModule (DC), Bridgeability::None, ImportTypeAttrs ());
2871
+ if (!underlyingType)
2872
+ return nullptr ;
2873
+
2874
+ auto structDecl = Impl.createDeclWithClangNode <StructDecl>(
2875
+ Decl, AccessLevel::Public, Loc, Name, Loc, None, nullptr , DC);
2876
+
2877
+ addSynthesizedProtocolAttrs (Impl, structDecl,
2878
+ {KnownProtocolKind::Sendable},
2879
+ /* isUnchecked=*/ true );
2880
+
2881
+ makeStructRawValued (Impl, structDecl, underlyingType,
2882
+ {KnownProtocolKind::OptionSet});
2883
+ auto selfType = structDecl->getDeclaredInterfaceType ();
2884
+ addSynthesizedTypealias (structDecl, ctx.Id_Element , selfType);
2885
+ addSynthesizedTypealias (structDecl, ctx.Id_ArrayLiteralElement ,
2886
+ selfType);
2887
+ Impl.DeclsWithSuperfluousTypedefs .insert (Decl);
2888
+
2889
+ Result = structDecl;
2890
+ } else {
2891
+ auto TypeAliasResult = Impl.createDeclWithClangNode <TypeAliasDecl>(
2892
+ Decl, AccessLevel::Public,
2893
+ Impl.importSourceLoc (Decl->getBeginLoc ()), SourceLoc (), Name, Loc,
2894
+ /* genericparams*/ nullptr , DC);
2895
+
2896
+ TypeAliasResult->setUnderlyingType (SwiftType);
2897
+ Result = TypeAliasResult;
2898
+ }
2867
2899
2868
2900
// Make Objective-C's 'id' unavailable.
2869
2901
if (Impl.SwiftContext .LangOpts .EnableObjCInterop && isObjCId (Decl)) {
0 commit comments