@@ -4065,12 +4065,10 @@ ReferenceCounting TypeBase::getReferenceCounting(
4065
4065
CanType type = getCanonicalType ();
4066
4066
ASTContext &ctx = type->getASTContext ();
4067
4067
4068
- // Determine which reference-counting scheme to use for an unknown object.
4069
- bool objCInterop = ctx.LangOpts .EnableObjCInterop ;
4070
- auto getUnknownObjectReferenceCounting = [objCInterop] {
4071
- return objCInterop ? ReferenceCounting::Unknown
4072
- : ReferenceCounting::Native;
4073
- };
4068
+ // In the absence of Objective-C interoperability, everything uses native
4069
+ // reference counting.
4070
+ if (!ctx.LangOpts .EnableObjCInterop )
4071
+ return ReferenceCounting::Native;
4074
4072
4075
4073
switch (type->getKind ()) {
4076
4074
#define SUGARED_TYPE (id, parent ) case TypeKind::id:
@@ -4083,11 +4081,10 @@ ReferenceCounting TypeBase::getReferenceCounting(
4083
4081
return ReferenceCounting::Native;
4084
4082
4085
4083
case TypeKind::BuiltinBridgeObject:
4086
- return objCInterop ? ReferenceCounting::Bridge
4087
- : ReferenceCounting::Native;
4084
+ return ReferenceCounting::Bridge;
4088
4085
4089
4086
case TypeKind::BuiltinUnknownObject:
4090
- return getUnknownObjectReferenceCounting () ;
4087
+ return ReferenceCounting::Unknown ;
4091
4088
4092
4089
case TypeKind::Class:
4093
4090
return getClassReferenceCounting (cast<ClassType>(type)->getDecl (),
@@ -4113,7 +4110,7 @@ ReferenceCounting TypeBase::getReferenceCounting(
4113
4110
(layout && layout->isRefCounted ()));
4114
4111
if (auto supertype = archetype->getSuperclass ())
4115
4112
return supertype->getReferenceCounting (resilience);
4116
- return getUnknownObjectReferenceCounting () ;
4113
+ return ReferenceCounting::Unknown ;
4117
4114
}
4118
4115
4119
4116
case TypeKind::Protocol:
@@ -4122,7 +4119,7 @@ ReferenceCounting TypeBase::getReferenceCounting(
4122
4119
assert (layout.requiresClass () && " Opaque existentials don't use refcounting" );
4123
4120
if (auto superclass = layout.getSuperclass ())
4124
4121
return superclass->getReferenceCounting (resilience);
4125
- return getUnknownObjectReferenceCounting () ;
4122
+ return ReferenceCounting::Unknown ;
4126
4123
}
4127
4124
4128
4125
case TypeKind::Function:
0 commit comments