@@ -3590,20 +3590,6 @@ namespace {
3590
3590
}
3591
3591
}
3592
3592
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
-
3607
3593
auto member = Impl.importDecl (nd, getActiveSwiftVersion ());
3608
3594
if (!member) {
3609
3595
if (!isa<clang::TypeDecl>(nd) && !isa<clang::FunctionDecl>(nd)) {
@@ -3629,16 +3615,8 @@ namespace {
3629
3615
methods.push_back (MD);
3630
3616
continue ;
3631
3617
}
3632
- auto VD = cast<VarDecl>(member);
3633
3618
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));
3642
3620
}
3643
3621
3644
3622
for (auto nestedType : nestedTypes) {
@@ -3977,6 +3955,14 @@ namespace {
3977
3955
if (!dc)
3978
3956
return nullptr ;
3979
3957
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
+
3980
3966
auto importedType =
3981
3967
Impl.importType (decl->getType (), ImportTypeKind::Variable,
3982
3968
isInSystemModule (dc), Bridgeability::None);
@@ -4002,6 +3988,12 @@ namespace {
4002
3988
if (correctSwiftName)
4003
3989
markAsVariant (result, *correctSwiftName);
4004
3990
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
+
4005
3997
return result;
4006
3998
}
4007
3999
0 commit comments