mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Objective-C class references (which show up in the __objc_classrefs section) are always coalesced by the linker. When we relatively address them (which occurs in protocol conformance records), the linker may compute the relative offset *before* coalescing, leading to an incorrect result. The net effect is a protocol conformance record that applies to the wrong Objective-C class, causing all sorts of runtime mayhem. Switch relatively-addressed Objective-C classes over to using the Objective-C runtime name of the class. It's a less efficient encoding (since we need to go through objc_lookUpClass), but it avoids the linker bug. Fixes rdar://problem/46428085 by working around the linker bug.
18 lines
650 B
Swift
18 lines
650 B
Swift
// RUN: %target-swift-frontend -enable-objc-interop -I %S/../Inputs/custom-modules %s -emit-ir | %FileCheck %s
|
|
|
|
import ObjCRuntimeVisible
|
|
|
|
protocol MyProtocol {}
|
|
protocol YourProtocol {}
|
|
|
|
extension A : MyProtocol {}
|
|
extension A : YourProtocol {}
|
|
|
|
// CHECK-LABEL: @"$sSo1AC32objc_runtime_visible_conformance10MyProtocolACMc"
|
|
// CHECK-SAME: @"$s32objc_runtime_visible_conformance10MyProtocolMp"
|
|
// CHECK-SAME: [[STRING_A:@[0-9]+]]
|
|
// CHECK-SAME: @"$sSo1AC32objc_runtime_visible_conformance10MyProtocolACWP"
|
|
// DirectObjCClassName
|
|
// CHECK-SAME: i32 16
|
|
// CHECK: [[STRING_A]] = private constant [22 x i8] c"MyRuntimeVisibleClass\00"
|