File: protocol_getter.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (32 lines) | stat: -rw-r--r-- 1,784 bytes parent folder | download
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
// RUN: %target-swift-frontend %s -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>
}