mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Find all the usages of `--enable-experimental-feature` or `--enable-upcoming-feature` in the tests and replace some of the `REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which should correctly apply to depending on the asserts/noasserts mode of the toolchain for each feature. Remove some comments that talked about enabling asserts since they don't apply anymore (but I might had miss some). All this was done with an automated script, so some formatting weirdness might happen, but I hope I fixed most of those. There might be some tests that were `REQUIRES: asserts` that might run in `noasserts` toolchains now. This will normally be because their feature went from experimental to upcoming/base and the tests were not updated.
65 lines
2.6 KiB
Swift
65 lines
2.6 KiB
Swift
// RUN: %target-swift-frontend -emit-sil %s -enable-experimental-feature TupleConformances | %FileCheck %s
|
|
|
|
// REQUIRES: swift_feature_TupleConformances
|
|
|
|
public typealias Tuple<each T> = (repeat each T)
|
|
|
|
public protocol P {
|
|
static func protocolMethod()
|
|
}
|
|
|
|
extension Tuple: P where repeat each T: P {
|
|
public static func protocolMethod() {}
|
|
}
|
|
|
|
extension Int: P {
|
|
public static func protocolMethod() {}
|
|
}
|
|
|
|
public func callee<T: P>(t: T.Type) {
|
|
}
|
|
|
|
@_transparent
|
|
public func transparentCallee<T: P>(t: T.Type) {
|
|
t.protocolMethod()
|
|
}
|
|
|
|
// Make sure we don't devirtualize the call when we inline transparentCallee()
|
|
// into transparentCaller(), because we might unwrap the tuple conformance
|
|
// later.
|
|
|
|
// CHECK-LABEL: sil [transparent] @$s4main17transparentCaller5tupleyxxQp_tm_tRvzAA1PRzlF : $@convention(thin) <each T where repeat each T : P> (@thin (repeat each T).Type) -> () {
|
|
@_transparent public func transparentCaller<each T: P>(tuple: (repeat each T).Type) {
|
|
callee(t: tuple)
|
|
|
|
// CHECK: [[FN:%.*]] = witness_method $(repeat each T), #P.protocolMethod : <Self where Self : P> (Self.Type) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> ()
|
|
// CHECK: apply [[FN:%.*]]<(repeat each T)>({{.*}})
|
|
|
|
transparentCallee(t: tuple)
|
|
|
|
// FIXME: This one is wrong in the AST
|
|
tuple.protocolMethod()
|
|
}
|
|
|
|
// Inlining transparentCaller() into caller() exercises the code path to unwrap
|
|
// a one-element tuple conformance.
|
|
|
|
public func caller() {
|
|
transparentCaller(tuple: Int.self)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s4main6calleryyF : $@convention(thin) () -> () {
|
|
// CHECK: [[FN:%.*]] = function_ref @$s4main6callee1tyxm_tAA1PRzlF : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> ()
|
|
// CHECK: apply [[FN]]<Int>({{.*}}) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> ()
|
|
|
|
// Make sure the witness method call in transparentCallee() was devirtualized to Int.protocolMethod().
|
|
|
|
// CHECK: [[FN:%.*]] = function_ref @$sSi4mainE14protocolMethodyyFZ : $@convention(method) (@thin Int.Type) -> () // user: %6
|
|
// CHECK: apply [[FN]]({{.*}}) : $@convention(method) (@thin Int.Type) -> ()
|
|
|
|
// FIXME: This is the `tuple.protocolMethod()` in transparentCaller(). It should
|
|
// also refer to Int.protocolMethod()!
|
|
|
|
// CHECK: [[FN:%.*]] = function_ref @$sBT4mainRvzAA1PRzlE14protocolMethodyyFZ : $@convention(method) <each τ_0_0 where repeat each τ_0_0 : P> (@thin (repeat each τ_0_0).Type) -> ()
|
|
// CHECK: apply [[FN]]<Pack{Int}>({{.*}}) : $@convention(method) <each τ_0_0 where repeat each τ_0_0 : P> (@thin (repeat each τ_0_0).Type) -> ()
|