mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
57 lines
1.6 KiB
Swift
57 lines
1.6 KiB
Swift
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -target %target-swift-5.9-abi-triple %s | %FileCheck %s
|
|
|
|
public class A<each T> {
|
|
public func f(_ action: (repeat each T) -> ()) {}
|
|
}
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s4main5test02fnyySi_SftXE_tF :
|
|
// CHECK: [[CTOR:%.*]] = function_ref @$s4main1ACACyxxQp_QPGycfC :
|
|
// CHECK: [[OBJECT:%.*]] = apply [[CTOR]]<Pack{Int, Float}>
|
|
// CHECK: [[METHOD:%.*]] = class_method [[OBJECT]] : $A<Int, Float>, #A.f : <each T> (A<repeat each T>) -> ((repeat each T) -> ()) -> ()
|
|
// CHECK: apply [[METHOD]]<Pack{Int, Float}>
|
|
func test0(fn: (Int, Float) -> ()) {
|
|
A<Int, Float>().f(fn)
|
|
}
|
|
|
|
// CHECK-LABEL: sil hidden [ossa] @$s4main5test1yyF :
|
|
// CHECK: [[CTOR:%.*]] = function_ref @$s4main1ACACyxxQp_QPGycfC :
|
|
// CHECK: [[OBJECT:%.*]] = apply [[CTOR]]<Pack{Int, Float}>
|
|
// CHECK: [[METHOD:%.*]] = class_method [[OBJECT]] : $A<Int, Float>, #A.f : <each T> (A<repeat each T>) -> ((repeat each T) -> ()) -> ()
|
|
// CHECK: apply [[METHOD]]<Pack{Int, Float}>
|
|
func test1() {
|
|
A<Int, Float>().f { a, b in }
|
|
}
|
|
|
|
// These are all currently forbidden
|
|
#if false
|
|
public class B<each T> : A<repeat each T> {
|
|
public override func f(_ action: (repeat each T) -> ()) {
|
|
super.f(action)
|
|
}
|
|
}
|
|
|
|
func test2() {
|
|
B<Int, Float>().f { a, b in }
|
|
}
|
|
|
|
public class C<T, each U> : A<T, repeat each U> {
|
|
public override func f(_ action: (T, repeat each U) -> ()) {
|
|
super.f(action)
|
|
}
|
|
}
|
|
|
|
func test3() {
|
|
C<Int, Float>().f { a, b in }
|
|
}
|
|
|
|
public class D : A<Int, Float> {
|
|
public override func f(_ action: (Int, Float) -> ()) {
|
|
super.f(action)
|
|
}
|
|
}
|
|
|
|
func test4() {
|
|
D().f { a, b in }
|
|
}
|
|
#endif
|