@@ -272,13 +272,13 @@ namespace {
272
272
return visitAbstractTypeParamType (type);
273
273
}
274
274
275
- bool hasNativeReferenceCounting (CanType type) {
275
+ Type getConcreteReferenceStorageReferent (Type type) {
276
276
if (type->isTypeParameter ()) {
277
277
auto signature = getGenericSignature ();
278
278
assert (signature && " dependent type without generic signature?!" );
279
279
280
280
if (auto concreteType = signature->getConcreteType (type))
281
- return hasNativeReferenceCounting ( concreteType->getCanonicalType () );
281
+ return concreteType->getCanonicalType ();
282
282
283
283
assert (signature->requiresClass (type));
284
284
@@ -288,17 +288,14 @@ namespace {
288
288
// at some point the type-checker should prove acyclic-ness.
289
289
auto bound = signature->getSuperclassBound (type);
290
290
if (bound) {
291
- return hasNativeReferenceCounting (bound->getCanonicalType ());
291
+ return getConcreteReferenceStorageReferent (bound->getCanonicalType ());
292
292
}
293
293
294
- // Ask whether Builtin.UnknownObject uses native reference counting.
295
294
auto &ctx = M.getASTContext ();
296
- return ctx.TheUnknownObjectType ->
297
- usesNativeReferenceCounting (ResilienceExpansion::Maximal);
295
+ return ctx.TheUnknownObjectType ;
298
296
}
299
297
300
- // FIXME: resilience
301
- return type->usesNativeReferenceCounting (ResilienceExpansion::Maximal);
298
+ return type;
302
299
}
303
300
304
301
#define NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
@@ -321,7 +318,11 @@ namespace {
321
318
IsAddressOnly}); \
322
319
} \
323
320
RetTy visit##Name##StorageType(Can##Name##StorageType type) { \
324
- if (type->isLoadable (ResilienceExpansion::Maximal)) { \
321
+ auto referentType = type->getReferentType (); \
322
+ auto concreteType = getConcreteReferenceStorageReferent (referentType); \
323
+ auto &ctx = M.getASTContext (); \
324
+ if (Name##StorageType::get (concreteType, ctx) \
325
+ ->isLoadable (ResilienceExpansion::Maximal)) { \
325
326
return asImpl ().visitLoadable ##Name##StorageType (type); \
326
327
} else { \
327
328
return asImpl ().visitAddressOnly ##Name##StorageType (type); \
0 commit comments