@@ -818,6 +818,31 @@ static bool isPrintLikeMethod(DeclName name, const DeclContext *dc) {
818
818
using MirroredMethodEntry =
819
819
std::tuple<const clang::ObjCMethodDecl*, ProtocolDecl*, bool /* isAsync*/ >;
820
820
821
+ ImportedType findOptionSetType (clang::QualType type,
822
+ ClangImporter::Implementation &Impl) {
823
+ ImportedType importedType;
824
+ auto fieldType = type;
825
+ if (auto elaborated = dyn_cast<clang::ElaboratedType>(fieldType))
826
+ fieldType = elaborated->desugar ();
827
+ if (auto typedefType = dyn_cast<clang::TypedefType>(fieldType)) {
828
+ if (Impl.isUnavailableInSwift (typedefType->getDecl ())) {
829
+ if (auto clangEnum =
830
+ findAnonymousEnumForTypedef (Impl.SwiftContext , typedefType)) {
831
+ // If this fails, it means that we need a stronger predicate for
832
+ // determining the relationship between an enum and typedef.
833
+ assert (
834
+ clangEnum.value ()->getIntegerType ()->getCanonicalTypeInternal () ==
835
+ typedefType->getCanonicalTypeInternal ());
836
+ if (auto swiftEnum = Impl.importDecl (*clangEnum, Impl.CurrentVersion )) {
837
+ importedType = {cast<TypeDecl>(swiftEnum)->getDeclaredInterfaceType (),
838
+ false };
839
+ }
840
+ }
841
+ }
842
+ }
843
+ return importedType;
844
+ }
845
+
821
846
namespace {
822
847
// / Customized llvm::DenseMapInfo for storing borrowed APSInts.
823
848
struct APSIntRefDenseMapInfo {
@@ -3658,23 +3683,8 @@ namespace {
3658
3683
return nullptr ;
3659
3684
}
3660
3685
3661
- ImportedType importedType;
3662
3686
auto fieldType = decl->getType ();
3663
- if (auto elaborated = dyn_cast<clang::ElaboratedType>(fieldType))
3664
- fieldType = elaborated->desugar ();
3665
- if (auto typedefType = dyn_cast<clang::TypedefType>(fieldType)) {
3666
- if (Impl.isUnavailableInSwift (typedefType->getDecl ())) {
3667
- if (auto clangEnum = findAnonymousEnumForTypedef (Impl.SwiftContext , typedefType)) {
3668
- // If this fails, it means that we need a stronger predicate for
3669
- // determining the relationship between an enum and typedef.
3670
- assert (clangEnum.value ()->getIntegerType ()->getCanonicalTypeInternal () ==
3671
- typedefType->getCanonicalTypeInternal ());
3672
- if (auto swiftEnum = Impl.importDecl (*clangEnum, Impl.CurrentVersion )) {
3673
- importedType = {cast<TypeDecl>(swiftEnum)->getDeclaredInterfaceType (), false };
3674
- }
3675
- }
3676
- }
3677
- }
3687
+ ImportedType importedType = findOptionSetType (fieldType, Impl);
3678
3688
3679
3689
if (!importedType)
3680
3690
importedType =
@@ -5199,7 +5209,11 @@ namespace {
5199
5209
}
5200
5210
}
5201
5211
5202
- auto importedType = Impl.importPropertyType (decl, isInSystemModule (dc));
5212
+ auto fieldType = decl->getType ();
5213
+ ImportedType importedType = findOptionSetType (fieldType, Impl);
5214
+
5215
+ if (!importedType)
5216
+ importedType = Impl.importPropertyType (decl, isInSystemModule (dc));
5203
5217
if (!importedType) {
5204
5218
Impl.addImportDiagnostic (
5205
5219
decl, Diagnostic (diag::objc_property_not_imported, decl),
0 commit comments