|
5 | 5 |
|
6 | 6 | // RUN: %target-swift-ide-test -source-filename=x -print-module -module-to-print Lib -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -enable-experimental-deserialization-recovery | %FileCheck -check-prefix CHECK-RECOVERY %s
|
7 | 7 |
|
| 8 | +// RUN: %target-swift-frontend -typecheck %s -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -enable-experimental-deserialization-recovery -D TEST -verify |
| 9 | + |
8 | 10 | // REQUIRES: objc_interop
|
9 | 11 |
|
| 12 | +#if TEST |
| 13 | +import Lib |
| 14 | + |
| 15 | +func testInitializers() { |
| 16 | + _ = D1_DesignatedInitDisappears() |
| 17 | + _ = D1_DesignatedInitDisappears(value: 0) // expected-error {{incorrect argument label in call}} |
| 18 | + _ = D1_DesignatedInitDisappears(convenience: 0) |
| 19 | + |
| 20 | + _ = D2_OnlyDesignatedInitDisappears(value: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 21 | + _ = D2_OnlyDesignatedInitDisappears(convenience: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 22 | + |
| 23 | + _ = D3_ConvenienceInitDisappears() |
| 24 | + _ = D3_ConvenienceInitDisappears(value: 0) // expected-error {{incorrect argument label in call}} |
| 25 | + _ = D3_ConvenienceInitDisappears(convenience: 0) |
| 26 | + |
| 27 | + _ = D4_UnknownInitDisappears() |
| 28 | + _ = D4_UnknownInitDisappears(value: 0) // expected-error {{argument passed to call that takes no arguments}} |
| 29 | + |
| 30 | + // FIXME: Why does 'init()' show up in the generated interface if it can't be |
| 31 | + // called? |
| 32 | + _ = D5_OnlyUnknownInitDisappears() // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 33 | + _ = D5_OnlyUnknownInitDisappears(value: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 34 | +} |
| 35 | + |
| 36 | +func testSubclassInitializers() { |
| 37 | + class DesignatedInitDisappearsSub : D1_DesignatedInitDisappears {} |
| 38 | + _ = DesignatedInitDisappearsSub() |
| 39 | + _ = DesignatedInitDisappearsSub(value: 0) // expected-error {{argument passed to call that takes no arguments}} |
| 40 | + _ = DesignatedInitDisappearsSub(convenience: 0) // expected-error {{argument passed to call that takes no arguments}} |
| 41 | + |
| 42 | + class OnlyDesignatedInitDisappearsSub : D2_OnlyDesignatedInitDisappears {} |
| 43 | + _ = OnlyDesignatedInitDisappearsSub(value: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 44 | + _ = OnlyDesignatedInitDisappearsSub(convenience: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 45 | + |
| 46 | + class ConvenienceInitDisappearsSub : D3_ConvenienceInitDisappears {} |
| 47 | + _ = ConvenienceInitDisappearsSub() |
| 48 | + _ = ConvenienceInitDisappearsSub(value: 0) // expected-error {{incorrect argument label in call}} |
| 49 | + _ = ConvenienceInitDisappearsSub(convenience: 0) // still inheritable |
| 50 | + |
| 51 | + class UnknownInitDisappearsSub : D4_UnknownInitDisappears {} |
| 52 | + _ = UnknownInitDisappearsSub() |
| 53 | + _ = UnknownInitDisappearsSub(value: 0) // expected-error {{argument passed to call that takes no arguments}} |
| 54 | + |
| 55 | + class OnlyUnknownInitDisappearsSub : D5_OnlyUnknownInitDisappears {} |
| 56 | + _ = OnlyUnknownInitDisappearsSub() // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 57 | + _ = OnlyUnknownInitDisappearsSub(value: 0) // expected-error {{cannot be constructed because it has no accessible initializers}} |
| 58 | +} |
| 59 | + |
| 60 | +#else // TEST |
| 61 | + |
10 | 62 | import Overrides
|
11 | 63 |
|
12 | 64 | // Please use prefixes to keep the printed parts of this file in alphabetical
|
@@ -111,3 +163,74 @@ public class C4_GenericKeyedSubscriptDisappears : GenericKeyedSubscriptDisappear
|
111 | 163 | // CHECK-RECOVERY-LABEL: class C4_GenericKeyedSubscriptDisappears : GenericKeyedSubscriptDisappearsBase<Base> {
|
112 | 164 | // CHECK-RECOVERY-NEXT: init()
|
113 | 165 | // CHECK-RECOVERY-NEXT: {{^}$}}
|
| 166 | + |
| 167 | + |
| 168 | +open class D1_DesignatedInitDisappears : DesignatedInitDisappearsBase { |
| 169 | + public override init() { fatalError() } |
| 170 | + public override init(value: Int) { fatalError() } |
| 171 | +} |
| 172 | + |
| 173 | +// CHECK-LABEL: class D1_DesignatedInitDisappears : DesignatedInitDisappearsBase { |
| 174 | +// CHECK-NEXT: init() |
| 175 | +// CHECK-NEXT: init(value: Int) |
| 176 | +// CHECK-NEXT: {{^}$}} |
| 177 | + |
| 178 | +// CHECK-RECOVERY-LABEL: class D1_DesignatedInitDisappears : DesignatedInitDisappearsBase { |
| 179 | +// CHECK-RECOVERY-NEXT: init() |
| 180 | +// CHECK-RECOVERY-NEXT: {{^}$}} |
| 181 | + |
| 182 | + |
| 183 | +open class D2_OnlyDesignatedInitDisappears : OnlyDesignatedInitDisappearsBase { |
| 184 | + public override init(value: Int) { fatalError() } |
| 185 | +} |
| 186 | + |
| 187 | +// CHECK-LABEL: class D2_OnlyDesignatedInitDisappears : OnlyDesignatedInitDisappearsBase { |
| 188 | +// CHECK-NEXT: init(value: Int) |
| 189 | +// CHECK-NEXT: {{^}$}} |
| 190 | + |
| 191 | +// CHECK-RECOVERY-LABEL: class D2_OnlyDesignatedInitDisappears : OnlyDesignatedInitDisappearsBase { |
| 192 | +// CHECK-RECOVERY-NEXT: {{^}$}} |
| 193 | + |
| 194 | + |
| 195 | +open class D3_ConvenienceInitDisappears : ConvenienceInitDisappearsBase { |
| 196 | + public override init() { fatalError() } |
| 197 | +} |
| 198 | + |
| 199 | +// CHECK-LABEL: class D3_ConvenienceInitDisappears : ConvenienceInitDisappearsBase { |
| 200 | +// CHECK-NEXT: init() |
| 201 | +// CHECK-NEXT: {{^}$}} |
| 202 | + |
| 203 | +// CHECK-RECOVERY-LABEL: class D3_ConvenienceInitDisappears : ConvenienceInitDisappearsBase { |
| 204 | +// CHECK-RECOVERY-NEXT: init() |
| 205 | +// CHECK-RECOVERY-NEXT: {{^}$}} |
| 206 | + |
| 207 | + |
| 208 | +open class D4_UnknownInitDisappears : UnknownInitDisappearsBase { |
| 209 | + public override init() { fatalError() } |
| 210 | + public override init(value: Int) { fatalError() } |
| 211 | +} |
| 212 | + |
| 213 | +// CHECK-LABEL: class D4_UnknownInitDisappears : UnknownInitDisappearsBase { |
| 214 | +// CHECK-NEXT: init() |
| 215 | +// CHECK-NEXT: init(value: Int) |
| 216 | +// CHECK-NEXT: {{^}$}} |
| 217 | + |
| 218 | +// CHECK-RECOVERY-LABEL: class D4_UnknownInitDisappears : UnknownInitDisappearsBase { |
| 219 | +// CHECK-RECOVERY-NEXT: init() |
| 220 | +// CHECK-RECOVERY-NEXT: {{^}$}} |
| 221 | + |
| 222 | + |
| 223 | +open class D5_OnlyUnknownInitDisappears : OnlyUnknownInitDisappearsBase { |
| 224 | + public override init(value: Int) { fatalError() } |
| 225 | +} |
| 226 | + |
| 227 | +// CHECK-LABEL: class D5_OnlyUnknownInitDisappears : OnlyUnknownInitDisappearsBase { |
| 228 | +// CHECK-NEXT: init(value: Int) |
| 229 | +// CHECK-NEXT: init() |
| 230 | +// CHECK-NEXT: {{^}$}} |
| 231 | + |
| 232 | +// CHECK-RECOVERY-LABEL: class D5_OnlyUnknownInitDisappears : OnlyUnknownInitDisappearsBase { |
| 233 | +// CHECK-RECOVERY-NEXT: init() |
| 234 | +// CHECK-RECOVERY-NEXT: {{^}$}} |
| 235 | + |
| 236 | +#endif // TEST |
0 commit comments