Files
swift-mirror/test/IRGen/objc_bridged_generic_conformance.swift
Doug Gregor 50b5044abb [IRGen] Don't emit relative references to Objective-C class references.
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.
2018-12-06 17:05:52 -08:00

16 lines
538 B
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -primary-file %s -enable-objc-interop -import-objc-header %S/Inputs/objc_bridged_generic_conformance.h | %FileCheck %s
// CHECK-NOT: _TMnCSo
// CHECK: @"$sSo6ThingyCyxG32objc_bridged_generic_conformance1PADMc" = hidden constant %swift.protocol_conformance_descriptor {{.*}} @[[THINGY_NAME:[0-9]]]
// CHECK: @[[THINGY_NAME]] = private constant [7 x i8] c"Thingy\00"
// CHECK-NOT: _TMnCSo
protocol P { func test() }
extension Thingy: P {
@objc func test() {}
}