File: inherits-superclass-initializers.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 (82 lines) | stat: -rw-r--r-- 2,232 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
// Note: this test has a client: inherits-superclass-initializers-client.swift

// RUN: %empty-directory(%t)

// RUN: %target-swift-emit-module-interface(%t/Module.swiftinterface) %s -module-name Module
// RUN: %target-swift-typecheck-module-from-interface(%t/Module.swiftinterface) -module-name Module
// RUN: %FileCheck %s < %t/Module.swiftinterface

// CHECK: @_hasMissingDesignatedInitializers open class Base {
open class Base {
  // CHECK-NEXT: public init(arg: Swift.Int)
  public init(arg: Int) {
    print("public init from Base")
  }
  // CHECK-NOT: init(secret: Swift.Int)
  internal init(secret: Int) {
    print("secret init from Base")
  }

  // CHECK: convenience public init()
  public convenience init() {
    self.init(secret: 4)
  }

// CHECK: }
}

// CHECK-NOT: @_hasMissingDesignatedInitializers
// CHECK: open class InlineBase {
open class InlineBase {
  // CHECK-NEXT: public init(arg: Swift.Int)
  public init(arg: Int) {
    print("public init from Inline Base")
  }

  // CHECK-NOT: @usableFromInline init(secret: Swift.Int)
  @usableFromInline
  internal init(secret: Int) {
    print("secret init from Inline Base")
  }

  // CHECK: convenience public init()
  public convenience init() {
    self.init(secret: 42)
  }
  // CHECK: }
}

// CHECK: @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers public class Sub : Module.Base {
public class Sub : Base {
  // CHECK: override public init(arg: Swift.Int)
  public override init(arg: Int) {
    print("public init from Sub")
    super.init(arg: arg)
  }
  // CHECK-NOT: init(secret: Swift.Int)
  internal override init(secret: Int) {
    print("secret init from Sub")
    super.init(secret: secret)
  }
// CHECK: }
}

// CHECK: @_inheritsConvenienceInitializers @_hasMissingDesignatedInitializers public class SubSub : Module.Sub {
public class SubSub: Sub {
  // CHECK: override public init(arg: Swift.Int)
  public override init(arg: Int) {
    print("public init from SubSub")
    super.init(arg: arg)
  }
  // CHECK-NOT: init(secret: Swift.Int)
  internal override init(secret: Int) {
    print("secret init from SubSub")
    super.init(secret: secret)
  }
// CHECK: }
}

@inlinable public func test() {
  _ = Sub()
  _ = SubSub()
}