@@ -5705,14 +5705,35 @@ SwiftDeclConverter::getImplicitProperty(ImportedName importedName,
5705
5705
if (dc->isTypeContext () && !getterName.getSelfIndex ())
5706
5706
isStatic = true ;
5707
5707
5708
- // Compute the property type.
5709
- bool isFromSystemModule = isInSystemModule (dc);
5710
- auto importedType = Impl.importType (
5711
- propertyType, ImportTypeKind::Property,
5712
- ImportDiagnosticAdder (Impl, getter, getter->getLocation ()),
5713
- Impl.shouldAllowNSUIntegerAsInt (isFromSystemModule, getter),
5714
- Bridgeability::Full, getImportTypeAttrs (accessor),
5715
- OTK_ImplicitlyUnwrappedOptional);
5708
+ ImportedType importedType;
5709
+
5710
+ // Sometimes we import unavailable typedefs as enums. If that's the case,
5711
+ // use the enum, not the typedef here.
5712
+ if (auto typedefType = dyn_cast<clang::TypedefType>(propertyType.getTypePtr ())) {
5713
+ if (Impl.isUnavailableInSwift (typedefType->getDecl ())) {
5714
+ if (auto clangEnum = findAnonymousEnumForTypedef (Impl.SwiftContext , typedefType)) {
5715
+ // If this fails, it means that we need a stronger predicate for
5716
+ // determining the relationship between an enum and typedef.
5717
+ assert (clangEnum.getValue ()->getIntegerType ()->getCanonicalTypeInternal () ==
5718
+ typedefType->getCanonicalTypeInternal ());
5719
+ if (auto swiftEnum = Impl.importDecl (*clangEnum, Impl.CurrentVersion )) {
5720
+ importedType = {cast<NominalTypeDecl>(swiftEnum)->getDeclaredType (), false };
5721
+ }
5722
+ }
5723
+ }
5724
+ }
5725
+
5726
+ if (!importedType) {
5727
+ // Compute the property type.
5728
+ bool isFromSystemModule = isInSystemModule (dc);
5729
+ importedType = Impl.importType (
5730
+ propertyType, ImportTypeKind::Property,
5731
+ ImportDiagnosticAdder (Impl, getter, getter->getLocation ()),
5732
+ Impl.shouldAllowNSUIntegerAsInt (isFromSystemModule, getter),
5733
+ Bridgeability::Full, getImportTypeAttrs (accessor),
5734
+ OTK_ImplicitlyUnwrappedOptional);
5735
+ }
5736
+
5716
5737
if (!importedType)
5717
5738
return nullptr ;
5718
5739
0 commit comments