Files
swift-mirror/test/SIL/Parser/protocol_getter.sil
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
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.
2024-11-21 18:49:52 +01:00

33 lines
1.8 KiB
Plaintext

// RUN: %target-swift-frontend %s -Xllvm -sil-print-types -emit-silgen | %FileCheck %s
// Verify that SILParser correctly handles witness_method on a getter.
import Swift
protocol TestP : class {
var count: Int {get}
func test() -> String!
}
// CHECK-LABEL: sil @test
sil @test : $@convention(method) (TestP) -> () {
bb0(%0 : $TestP):
%1 = open_existential_ref %0 : $TestP to $@opened("01234567-89ab-cdef-0123-000000000000", TestP) Self
// CHECK: witness_method $@opened({{.*}}, any TestP) Self, #TestP.count!getter : {{.*}}, %{{.*}} : $@opened({{.*}} : $@convention(witness_method: TestP) <τ_0_0 where τ_0_0 : TestP> (τ_0_0) -> Int
%2 = witness_method $@opened("01234567-89ab-cdef-0123-000000000000", TestP) Self, #TestP.count!getter, %1 : $@opened("01234567-89ab-cdef-0123-000000000000", TestP) Self : $@convention(witness_method: TestP) <T: TestP> (T) -> Int
%3 = tuple ()
return %3 : $()
}
// Make sure we can parse "!" as ImplicitlyUnwrappedOptional.
// CHECK-LABEL: sil @top
sil @top : $@convention(thin) (@owned TestP) -> @owned Optional<String> {
bb0(%0 : $TestP):
strong_retain %0 : $TestP
%3 = open_existential_ref %0 : $TestP to $@opened("01234567-89ab-cdef-0123-111111111111", TestP) Self
// CHECK: witness_method $@opened({{.*}}, any TestP) Self, #TestP.test
%4 = witness_method $@opened("01234567-89ab-cdef-0123-111111111111", TestP) Self, #TestP.test, %3 : $@opened("01234567-89ab-cdef-0123-111111111111", TestP) Self : $@convention(witness_method: TestP) @callee_owned <T: TestP> (@owned T) -> @owned Optional<String>
%5 = apply %4<@opened("01234567-89ab-cdef-0123-111111111111", TestP) Self>(%3) : $@convention(witness_method: TestP) @callee_owned <T: TestP> (@owned T) -> @owned Optional<String>
strong_release %0 : $TestP
return %5 : $Optional<String>
}