File: super_method.swift

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 (99 lines) | stat: -rw-r--r-- 3,899 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
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
88
89
90
91
92
93
94
95
96
97
98
99
// RUN: %target-swift-frontend -emit-sil  %s | %FileCheck %s

class Parent {
  @inline(never)
  func onlyInParent() {}
  @inline(never)
  final func finalOnlyInParent() {}
  @inline(never)
  func foo() {}
}

class Child : Parent {}

class Grandchild : Child {
  // CHECK: sil hidden @$s12super_method10GrandchildC06onlyInC0yyF
  func onlyInGrandchild() {
    // CHECK-NOT: super_method %0 : $Grandchild, #Parent.onlyInParent : Parent -> () -> ()
    // CHECK: function_ref @$s12super_method6ParentC06onlyInC0yyF
    super.onlyInParent()
    // CHECK: function_ref @$s12super_method6ParentC011finalOnlyInC0yyF
    super.finalOnlyInParent()
  }

  // CHECK: sil hidden @$s12super_method10GrandchildC3fooyyF
  override func foo() {
    // CHECK-NOT: super_method %0 : $Grandchild, #Parent.foo : Parent -> () -> ()
    // CHECK: function_ref @$s12super_method6ParentC3fooyyF
    super.foo()
  }
}

class GenericParent<A> {
  let a: A
  init(a: A) {
    self.a = a
  }

  func onlyInParent() {}

  @inline(never)
  final func finalOnlyInParent() {}

  @inline(never)
  func method() {}

  @inline(never)
  class func classMethod() {}
}

class GenericChild<A> : GenericParent<A> {}

class GenericGrandchild<A> : GenericChild<A> {
  // CHECK-LABEL: sil hidden @$s12super_method17GenericGrandchildC06onlyInD0yyF : $@convention(method) <A> (@guaranteed GenericGrandchild<A>) -> ()
  func onlyInGrandchild() {
	// CHECK-NOT: super_method %
	// CHECK: function_ref @$s12super_method13GenericParentC06onlyInD0yyF
	// CHECK-NOT: super_method %
    super.onlyInParent()
	// CHECK-NOT: super_method %
    // CHECK: function_ref @$s12super_method13GenericParentC011finalOnlyInD0yyF : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> ()
	// CHECK-NOT: super_method %
    super.finalOnlyInParent()
  }
  // CHECK-LABEL: sil hidden @$s12super_method17GenericGrandchildC0B0yyF : $@convention(method) <A> (@guaranteed GenericGrandchild<A>) -> ()
  override func method() {
	// CHECK-NOT: super_method %
    // CHECK: function_ref @$s12super_method13GenericParentC0B0yyF
	// CHECK-NOT: super_method %
    super.method()
  }
}

class ConcreteChild : GenericParent<String> {
  // CHECK-LABEL: sil hidden @$s12super_method13ConcreteChildC1aACSS_tcfc : $@convention(method) (@owned String, @owned ConcreteChild) -> @owned ConcreteChild {
  override init(a: String) {
    // CHECK-NOT: super_method {{%[0-9]+}} : $ConcreteChild, #GenericParent.init!initializer
    // CHECK: [[INIT_FN_REF:%[0-9]+]] = function_ref @$s12super_method13GenericParentC1aACyxGx_tcfc : $@convention(method) <τ_0_0> (@in τ_0_0, @owned GenericParent<τ_0_0>) -> @owned GenericParent<τ_0_0>{{.*}}
    // CHECK: apply [[INIT_FN_REF]]
    // CHECK: } // end sil function '$s12super_method13ConcreteChildC1aACSS_tcfc'
    super.init(a: a)
  }
}

class ConcreteGrandchild : ConcreteChild {
  // CHECK-LABEL: sil hidden @$s12super_method18ConcreteGrandchildC06onlyInD0yyF : $@convention(method) (@guaranteed ConcreteGrandchild) -> ()
  func onlyInGrandchild() {
    // CHECK-NOT: super_method {{%[0-9]+}} : $ConcreteGrandchild, #GenericParent.onlyInParent
    // CHECK: function_ref @$s12super_method13GenericParentC06onlyInD0yyF : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> ()
    super.onlyInParent()
    // CHECK: function_ref @$s12super_method13GenericParentC011finalOnlyInD0yyF : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> ()
    super.finalOnlyInParent()
  }
  // CHECK-LABEL: sil hidden @$s12super_method18ConcreteGrandchildC0B0yyF : $@convention(method) (@guaranteed ConcreteGrandchild) -> ()
  override func method() {
    // CHECK-NOT: super_method {{%[0-9]+}} : $ConcreteGrandchild, #GenericParent.method
    // CHECK: function_ref @$s12super_method13GenericParentC0B0yyF : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> ()
    super.method()
  }
}