1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
// RUN: %target-run-simple-swift(%S/Inputs/main.swift %S/Inputs/consume-logging-metadata-value.swift -Xfrontend -prespecialize-generic-metadata -target %module-target-future) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: VENDOR=apple || OS=linux-gnu
// UNSUPPORTED: CPU=i386 && OS=ios
// UNSUPPORTED: CPU=armv7 && OS=ios
// UNSUPPORTED: CPU=armv7s && OS=ios
// Executing on the simulator within __abort_with_payload with "No ABI plugin located for triple x86_64h-apple-ios -- shared libraries will not be registered!"
// UNSUPPORTED: CPU=x86_64 && OS=ios
// UNSUPPORTED: CPU=x86_64 && OS=tvos
// UNSUPPORTED: CPU=x86_64 && OS=watchos
// UNSUPPORTED: CPU=i386 && OS=watchos
// UNSUPPORTED: use_os_stdlib
// rdar://87772056
// UNSUPPORTED: CPU=arm64e && OS=ios
class WeakMutableInstanceMethodBox<Input, Output> {
let line: UInt
init(line: UInt = #line) {
self.line = line
}
private var work: ((Input) -> Output?)?
func bind<T: AnyObject>(to object: T, method: @escaping (T) -> (Input) -> Output?) {
self.work = { [weak object] input in
guard let object = object else { return nil }
return method(object)(input)
}
}
func call(_ input: Input) -> Output? {
return work?(input)
}
}
extension WeakMutableInstanceMethodBox : CustomStringConvertible {
var description: String {
"\(type(of: self)) @ \(line)"
}
}
class MyWeakMutableInstanceMethodBox<Input, Output> : WeakMutableInstanceMethodBox<Input, Output> {
override init(line: UInt = #line) {
super.init(line: line)
}
}
@inline(never)
func consume<Input, Output>(base: WeakMutableInstanceMethodBox<Input, Output>) {
consume(base)
}
func consume<Input, Output>(derived: MyWeakMutableInstanceMethodBox<Input, Output>) {
consume(derived)
}
func doit() {
// CHECK: [[SUPERCLASS_METADATA_INT_BOOL_ADDRESS:[0-9a-f]+]] WeakMutableInstanceMethodBox<Int, Bool> @ 65
consume(WeakMutableInstanceMethodBox<Int, Bool>())
// CHECK: [[SUPERCLASS_METADATA_INT_BOOL_ADDRESS]] WeakMutableInstanceMethodBox<Int, Bool> @ 67
consume(base: WeakMutableInstanceMethodBox<Int, Bool>())
// CHECK: [[SUPERCLASS_METADATA_DOUBLE_FLOAT_ADDRESS:[0-9a-f]+]] WeakMutableInstanceMethodBox<Double, Float> @ 69
consume(WeakMutableInstanceMethodBox<Double, Float>())
// CHECK: [[SUPERCLASS_METADATA_DOUBLE_FLOAT_ADDRESS]] WeakMutableInstanceMethodBox<Double, Float> @ 71
consume(base: WeakMutableInstanceMethodBox<Double, Float>())
// CHECK: [[SUBCLASS_METADATA_INT_BOOL_ADDRESS:[0-9a-f]+]] MyWeakMutableInstanceMethodBox<Int, Bool> @ 74
consume(MyWeakMutableInstanceMethodBox<Int, Bool>())
// CHECK: [[SUPERCLASS_METADATA_INT_BOOL_ADDRESS]] MyWeakMutableInstanceMethodBox<Int, Bool> @ 76
consume(base: MyWeakMutableInstanceMethodBox<Int, Bool>())
// CHECK: [[SUBCLASS_METADATA_INT_BOOL_ADDRESS]] MyWeakMutableInstanceMethodBox<Int, Bool> @ 78
consume(derived: MyWeakMutableInstanceMethodBox<Int, Bool>())
// CHECK: [[SUBCLASS_METADATA_DOUBLE_FLOAT_ADDRESS:[0-9a-f]+]] MyWeakMutableInstanceMethodBox<Double, Float>
consume(MyWeakMutableInstanceMethodBox<Double, Float>())
// CHECK: [[SUPERCLASS_METADATA_DOUBLE_FLOAT_ADDRESS]] MyWeakMutableInstanceMethodBox<Double, Float>
consume(base: MyWeakMutableInstanceMethodBox<Double, Float>())
// CHECK: [[SUBCLASS_METADATA_DOUBLE_FLOAT_ADDRESS]] MyWeakMutableInstanceMethodBox<Double, Float>
consume(derived: MyWeakMutableInstanceMethodBox<Double, Float>())
}
|