@@ -3590,20 +3590,6 @@ namespace {
35903590 }
35913591 }
35923592
3593- // If we encounter an IndirectFieldDecl, ensure that its parent is
3594- // importable before attempting to import it because they are dependent
3595- // when it comes to getter/setter generation.
3596- if (const auto *ind = dyn_cast<clang::IndirectFieldDecl>(nd)) {
3597- const clang::CXXRecordDecl *parentUnion =
3598- (ind->getChainingSize () >= 2 )
3599- ? dyn_cast<clang::CXXRecordDecl>(
3600- ind->getAnonField ()->getParent ())
3601- : nullptr ;
3602- if (parentUnion && parentUnion->isAnonymousStructOrUnion () &&
3603- parentUnion->isUnion () && !isCxxRecordImportable (parentUnion))
3604- continue ;
3605- }
3606-
36073593 auto member = Impl.importDecl (nd, getActiveSwiftVersion ());
36083594 if (!member) {
36093595 if (!isa<clang::TypeDecl>(nd) && !isa<clang::FunctionDecl>(nd)) {
@@ -3629,16 +3615,8 @@ namespace {
36293615 methods.push_back (MD);
36303616 continue ;
36313617 }
3632- auto VD = cast<VarDecl>(member);
36333618
3634- if (isa<clang::IndirectFieldDecl>(nd) || decl->isUnion ()) {
3635- // Don't import unavailable fields that have no associated storage.
3636- if (VD->getAttrs ().isUnavailable (Impl.SwiftContext )) {
3637- continue ;
3638- }
3639- }
3640-
3641- members.push_back (VD);
3619+ members.push_back (cast<VarDecl>(member));
36423620 }
36433621
36443622 for (auto nestedType : nestedTypes) {
@@ -3977,6 +3955,14 @@ namespace {
39773955 if (!dc)
39783956 return nullptr ;
39793957
3958+ // If we encounter an IndirectFieldDecl, ensure that its parent is
3959+ // importable before attempting to import it because they are dependent
3960+ // when it comes to getter/setter generation.
3961+ if (auto parent =
3962+ dyn_cast<clang::CXXRecordDecl>(decl->getAnonField ()->getParent ()))
3963+ if (!isCxxRecordImportable (parent))
3964+ return nullptr ;
3965+
39803966 auto importedType =
39813967 Impl.importType (decl->getType (), ImportTypeKind::Variable,
39823968 isInSystemModule (dc), Bridgeability::None);
@@ -4002,6 +3988,12 @@ namespace {
40023988 if (correctSwiftName)
40033989 markAsVariant (result, *correctSwiftName);
40043990
3991+ // Don't import unavailable fields that have no associated storage.
3992+ // TODO: is there any way we could bail here before we allocate/construct
3993+ // the VarDecl?
3994+ if (result->getAttrs ().isUnavailable (Impl.SwiftContext ))
3995+ return nullptr ;
3996+
40053997 return result;
40063998 }
40073999
0 commit comments