mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
It looks like the only thing that fails is the linkage computation for the dynamic replacement key of class methods. Even though methods have hidden linkage to prevent them from being directly referenced from outside a resilient module, we need to ensure the dynamic replacement key is visible. Fixes <rdar://problem/58457716>.
61 lines
1.2 KiB
Swift
61 lines
1.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -o %t/main %target-rpath(%t) %s -swift-version 5
|
|
// RUN: %target-codesign %t/main
|
|
// RUN: %target-run %t/main | %FileCheck %s
|
|
|
|
// RUN: %target-build-swift -o %t/main %target-rpath(%t) %s -swift-version 5 -enable-library-evolution
|
|
// RUN: %target-codesign %t/main
|
|
// RUN: %target-run %t/main | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: swift_test_mode_optimize_none
|
|
// REQUIRES: CPU=arm64 || CPU=arm64e || CPU=x86_64
|
|
|
|
public protocol Assoc {
|
|
associatedtype A = Int
|
|
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
func act() -> A
|
|
}
|
|
|
|
|
|
func testAssociatedType<T: Assoc> (_ t: T) {
|
|
print(T.A.self)
|
|
|
|
}
|
|
|
|
protocol P {
|
|
}
|
|
|
|
extension Int : P {
|
|
}
|
|
|
|
struct Pair : P {}
|
|
|
|
struct Test : Assoc {
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
dynamic func act() -> some P {
|
|
return 1
|
|
}
|
|
}
|
|
|
|
extension Test {
|
|
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
|
@_dynamicReplacement(for: act)
|
|
func act_r() -> some P {
|
|
return Pair()
|
|
}
|
|
}
|
|
|
|
func test() {
|
|
let t = Test()
|
|
// CHECK: Pair
|
|
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
|
|
testAssociatedType(t)
|
|
} else {
|
|
print("Pair")
|
|
}
|
|
}
|
|
|
|
test()
|