diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index e2a9f164e3373..b06534faec1bf 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -38,7 +38,6 @@ #include #include "CallEmission.h" -#include "ClassTypeInfo.h" #include "EntryPointArgumentEmission.h" #include "Explosion.h" #include "GenCall.h" @@ -2613,19 +2612,9 @@ class SyncCallEmission final : public CallEmission { if (fnConv.getNumDirectSILResults() == 1 && (fnConv.getDirectSILResults().begin()->getConvention() == ResultConvention::Autoreleased)) { - if (IGF.IGM.Context.LangOpts.EnableObjCInterop) { - auto ty = fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext()); - // NOTE: We cannot dyn_cast directly to ClassTypeInfo since it does not - // implement 'classof', so will succeed for any ReferenceTypeInfo. - auto *refTypeInfo = dyn_cast(&IGF.IGM.getTypeInfo(ty)); - if (refTypeInfo && - refTypeInfo->getReferenceCountingType() == ReferenceCounting::Custom) { - Explosion e(result); - refTypeInfo->as().strongCustomRetain(IGF, e, true); - } else { - result = emitObjCRetainAutoreleasedReturnValue(IGF, result); - } - } else + if (IGF.IGM.Context.LangOpts.EnableObjCInterop) + result = emitObjCRetainAutoreleasedReturnValue(IGF, result); + else IGF.emitNativeStrongRetain(result, IGF.getDefaultAtomicity()); } diff --git a/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap b/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap index b74a1deb286b2..7d24443653651 100644 --- a/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap +++ b/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap @@ -28,12 +28,6 @@ module ReferenceCounted { requires cplusplus } -module ReferenceCountedObjCProperty { - header "reference-counted-objc-property.h" - requires cplusplus - export * -} - module MemberLayout { header "member-layout.h" requires cplusplus diff --git a/test/Interop/Cxx/foreign-reference/Inputs/reference-counted-objc-property.h b/test/Interop/Cxx/foreign-reference/Inputs/reference-counted-objc-property.h deleted file mode 100644 index 08932c40b658b..0000000000000 --- a/test/Interop/Cxx/foreign-reference/Inputs/reference-counted-objc-property.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef REFERENCE_COUNTED_OBJC_PROPERTY_H -#define REFERENCE_COUNTED_OBJC_PROPERTY_H - -#include "reference-counted.h" - -SWIFT_BEGIN_NULLABILITY_ANNOTATIONS - -@interface C0 -@property (nonnull, readonly) NS::LocalCount *lc; -- (instancetype)init; -@end - -SWIFT_END_NULLABILITY_ANNOTATIONS - -#endif // REFERENCE_COUNTED_OBJC_PROPERTY_H diff --git a/test/Interop/Cxx/foreign-reference/reference-counted-objc-property.swift b/test/Interop/Cxx/foreign-reference/reference-counted-objc-property.swift deleted file mode 100644 index 7f71c13053804..0000000000000 --- a/test/Interop/Cxx/foreign-reference/reference-counted-objc-property.swift +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %target-swift-emit-irgen %s -I %S/Inputs -cxx-interoperability-mode=default -Xcc -fno-exceptions -Xcc -fno-objc-exceptions | %FileCheck %s - -// REQUIRES: objc_interop - -import ReferenceCountedObjCProperty - -// CHECK: define swiftcc void @"$s4main10testGetteryyF"() -// CHECK: alloca ptr, align {{4|8}} -// CHECK: %[[LC:.*]] = alloca ptr, align {{4|8}} -// CHECK: %[[V4:.*]] = load ptr, ptr @"\01L_selector(lc)", align {{4|8}} -// CHECK: %[[V5:.*]] = call ptr @objc_msgSend(ptr %{{.*}}, ptr %[[V4]]) -// CHECK: %[[V6:.*]] = icmp ne ptr %[[V5]], null -// CHECK: br i1 %[[V6]], label %[[LIFETIME_NONNULL_VALUE:.*]], label %[[LIFETIME_CONT:.*]] - -// CHECK: [[LIFETIME_NONNULL_VALUE]]: -// CHECK-NEXT: call void @_Z8LCRetainPN2NS10LocalCountE(ptr %[[V5]]) -// CHECK-NEXT: br label %[[LIFETIME_CONT]] - -// CHECK: [[LIFETIME_CONT]]: -// CHECK: store ptr %[[V5]], ptr %[[LC]], align {{4|8}} -// CHECK: %[[TODESTROY:.*]] = load ptr, ptr %[[LC]], align {{4|8}} -// CHECK: call void @_Z9LCReleasePN2NS10LocalCountE(ptr %[[TODESTROY]]) - -public func testGetter() { - var c0 = C0() - var lc = c0.lc -}