|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | + |
| 3 | +// Generate the parseable interface of the current file via the merge-modules step |
| 4 | +// RUN: %target-build-swift -emit-module -o %t/Test.swiftmodule -emit-parseable-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s |
| 5 | + |
| 6 | +// Generate the parseable interface of the current file via a single frontend invocation |
| 7 | +// RUN: %target-swift-frontend -typecheck -enable-objc-interop -emit-parseable-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s |
| 8 | + |
| 9 | +// Make sure both don't add override for inits shadowing convenience initializers |
| 10 | +// RUN: %FileCheck --check-prefixes=CHECK,SINGLE %s < %t/TestSingle.swiftinterface |
| 11 | +// RUN: %FileCheck --check-prefixes=CHECK,MERGE %s < %t/TestMerge.swiftinterface |
| 12 | + |
| 13 | +// Check we can consume the interface without issue |
| 14 | +// RUN: %target-swift-frontend -swift-version 5 -build-module-from-parseable-interface -o %t/Test.swiftmodule %t/TestSingle.swiftinterface |
| 15 | +// RUN: %target-swift-frontend -swift-version 5 -build-module-from-parseable-interface -o %t/Test.swiftmodule %t/TestMerge.swiftinterface |
| 16 | + |
| 17 | +public class Base { |
| 18 | + let x: Int |
| 19 | + public init(x: Int) { |
| 20 | + self.x = x |
| 21 | + } |
| 22 | + convenience public init() { |
| 23 | + self.init(x: 1) |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +public class Derived: Base { |
| 28 | + // MERGE: {{^}} public init(z: Swift.Int) |
| 29 | + // SINGLE: {{^}} public init(z: Int) |
| 30 | + public init(z: Int) { |
| 31 | + super.init(x: z) |
| 32 | + } |
| 33 | + // MERGE: {{^}} public convenience init() |
| 34 | + // SINGLE: {{^}} convenience public init() |
| 35 | + convenience public init() { |
| 36 | + self.init(z: 1) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +public class Derived2: Base { |
| 41 | + // CHECK: {{^}} public init() |
| 42 | + public init() { |
| 43 | + super.init(x: 1) |
| 44 | + } |
| 45 | + |
| 46 | + // MERGE: {{^}} override public convenience init(x: Swift.Int) |
| 47 | + // SINGLE: {{^}} override convenience public init(x: Int) |
| 48 | + override convenience public init(x: Int) { |
| 49 | + self.init() |
| 50 | + } |
| 51 | +} |
0 commit comments