Skip to content

Bridge types during import only if we are in a fully-bridgeable context. #10832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ namespace {
SwiftType = Impl.importType(ClangType,
ImportTypeKind::Typedef,
isInSystemModule(DC),
ClangType->isBlockPointerType(),
getTypedefBridgeability(ClangType),
OTK_Optional);
}

Expand Down Expand Up @@ -2410,7 +2410,7 @@ namespace {
auto underlyingType = Impl.importType(decl->getIntegerType(),
ImportTypeKind::Enum,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!underlyingType)
return nullptr;

Expand Down Expand Up @@ -2447,7 +2447,7 @@ namespace {
// Compute the underlying type.
auto underlyingType = Impl.importType(
decl->getIntegerType(), ImportTypeKind::Enum, isInSystemModule(dc),
/*isFullyBridgeable*/ false);
Bridgeability::None);
if (!underlyingType)
return nullptr;

Expand Down Expand Up @@ -3063,7 +3063,7 @@ namespace {
auto type = Impl.importType(clangContext.getTagDeclType(clangEnum),
ImportTypeKind::Value,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!type)
return nullptr;
// FIXME: Importing the type will recursively revisit this same
Expand Down Expand Up @@ -3101,7 +3101,7 @@ namespace {
Impl.getClangASTContext().getTagDeclType(clangEnum),
ImportTypeKind::Value,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!enumType)
return nullptr;

Expand Down Expand Up @@ -3162,7 +3162,7 @@ namespace {
auto type = Impl.importType(decl->getType(),
ImportTypeKind::Variable,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!type)
return nullptr;

Expand Down Expand Up @@ -3385,7 +3385,7 @@ namespace {
auto type = Impl.importType(decl->getType(),
ImportTypeKind::RecordField,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!type)
return nullptr;

Expand Down Expand Up @@ -3454,7 +3454,7 @@ namespace {
(isAudited ? ImportTypeKind::AuditedVariable
: ImportTypeKind::Variable),
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);

if (!type)
return nullptr;
Expand Down Expand Up @@ -4332,7 +4332,7 @@ namespace {
superclassType = Impl.importType(clangSuperclassType,
ImportTypeKind::Abstract,
isInSystemModule(dc),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (superclassType) {
assert(superclassType->is<ClassType>() ||
superclassType->is<BoundGenericClassType>());
Expand Down Expand Up @@ -4938,7 +4938,7 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
// Import the type of the underlying storage
auto storedUnderlyingType = Impl.importType(
decl->getUnderlyingType(), ImportTypeKind::Value, isInSystemModule(dc),
decl->getUnderlyingType()->isBlockPointerType(), OTK_None);
Bridgeability::None, OTK_None);

if (auto objTy = storedUnderlyingType->getAnyOptionalObjectType())
storedUnderlyingType = objTy;
Expand All @@ -4956,7 +4956,7 @@ SwiftDeclConverter::importSwiftNewtype(const clang::TypedefNameDecl *decl,
// Find a bridged type, which may be different
auto computedPropertyUnderlyingType = Impl.importType(
decl->getUnderlyingType(), ImportTypeKind::Property, isInSystemModule(dc),
decl->getUnderlyingType()->isBlockPointerType(), OTK_None);
Bridgeability::Full, OTK_None);
if (auto objTy = computedPropertyUnderlyingType->getAnyOptionalObjectType())
computedPropertyUnderlyingType = objTy;

Expand Down Expand Up @@ -5173,7 +5173,7 @@ SwiftDeclConverter::importAsOptionSetType(DeclContext *dc, Identifier name,
// Compute the underlying type.
auto underlyingType = Impl.importType(
decl->getIntegerType(), ImportTypeKind::Enum, isInSystemModule(dc),
/*isFullyBridgeable*/ false);
Bridgeability::None);
if (!underlyingType)
return nullptr;

Expand Down Expand Up @@ -5492,7 +5492,7 @@ SwiftDeclConverter::getImplicitProperty(ImportedName importedName,
Type swiftPropertyType = Impl.importType(
propertyType, ImportTypeKind::Property,
Impl.shouldAllowNSUIntegerAsInt(isFromSystemModule, getter),
/*isFullyBridgeable*/ true, OTK_ImplicitlyUnwrappedOptional);
Bridgeability::Full, OTK_ImplicitlyUnwrappedOptional);
if (!swiftPropertyType)
return nullptr;

Expand Down Expand Up @@ -6406,7 +6406,8 @@ Optional<GenericParamList *> SwiftDeclConverter::importObjCGenericParams(
clangBound->stripObjCKindOfTypeAndQuals(Impl.getClangASTContext());
Type superclassType =
Impl.importType(clang::QualType(unqualifiedClangBound, 0),
ImportTypeKind::Abstract, false, false);
ImportTypeKind::Abstract, false,
Bridgeability::None);
if (!superclassType) {
return None;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ClangImporter/ImportMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
auto clangTy = parsed->getType();
auto literalType = Impl.importType(clangTy, ImportTypeKind::Value,
isInSystemModule(DC),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!literalType)
return nullptr;

Expand All @@ -123,7 +123,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
} else {
constantType = Impl.importType(castType, ImportTypeKind::Value,
isInSystemModule(DC),
/*isFullyBridgeable*/false);
Bridgeability::None);
if (!constantType)
return nullptr;
}
Expand Down Expand Up @@ -300,7 +300,7 @@ static Optional<std::pair<llvm::APSInt, Type>>
auto type = impl.importType(literal->getType(),
ImportTypeKind::Value,
isInSystemModule(DC),
/*isFullyBridgeable*/false);
Bridgeability::None);
return {{ value, type }};
}

Expand Down
Loading