Files
swift-mirror/test/Interpreter/dynamic_replacement_opaque_result2.swift
Slava Pestov 23cac673ca IRGen: Enable dynamic replacement with library evolution
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>.
2020-04-10 22:53:36 -04:00

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()