|
1 | 1 | // RUN: %target-swift-frontend -enable-relative-protocol-witness-tables -module-name A -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-cpu --check-prefix=CHECK |
2 | 2 |
|
| 3 | +// Test with resilience enabled. |
| 4 | +// In this mode we still assume protocols to be "fragile"/non changeable. |
| 5 | +// RUN: %target-swift-frontend -enable-resilience -enable-fragile-relative-protocol-tables -enable-relative-protocol-witness-tables -module-name A -primary-file %s -I %t -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-cpu --check-prefix=CHECK |
| 6 | +// RUN: %empty-directory(%t) |
| 7 | +// RUN: %target-swift-frontend -emit-module -enable-fragile-relative-protocol-tables -enable-library-evolution -enable-relative-protocol-witness-tables -emit-module-path=%t/resilient.swiftmodule -module-name=resilient %S/Inputs/relative_protocol_witness_tables2.swift |
| 8 | +// Inputs/relative_protocol_witness_tables2.swift |
| 9 | +// RUN: %target-swift-frontend -enable-fragile-relative-protocol-tables -enable-relative-protocol-witness-tables -module-name A -primary-file %s -I %t -emit-ir -DWITH_RESILIENCE | %FileCheck %s --check-prefix=CHECK-%target-cpu --check-prefix=CHECK |
| 10 | +// RUN: %target-swift-frontend -enable-fragile-relative-protocol-tables -enable-relative-protocol-witness-tables -module-name A -primary-file %s -I %t -emit-ir -DWITH_RESILIENCE | %FileCheck %s --check-prefix=EVO |
| 11 | +// RUN: not --crash %target-swift-frontend -enable-fragile-relative-protocol-tables -enable-relative-protocol-witness-tables -module-name A -primary-file %s -I %t -emit-ir -DWITH_RESILIENCE -DEXPECT_CRASH 2>&1 | %FileCheck %s --check-prefix=CRASH |
| 12 | + |
3 | 13 | // REQUIRES: CPU=x86_64 || CPU=arm64 || CPU=arm64e |
4 | 14 |
|
| 15 | +#if WITH_RESILIENCE |
| 16 | +import resilient |
| 17 | +#endif |
| 18 | + |
5 | 19 | func testVWT<T>(_ t: T) { |
6 | 20 | var local = t |
7 | 21 | } |
@@ -323,3 +337,30 @@ func instantiate_conditional_conformance_2nd<T>(_ t : T) where T: Sub, T.S == T |
323 | 337 | // CHECK: [[T26:%.*]] = call ptr @swift_getWitnessTableRelative({{.*}}@"$s1A1XVyxGAA4BaseA2aERzlMc{{.*}}, ptr {{.*}}, ptr [[T24]]) |
324 | 338 | // CHECK: [[T28:%.*]] = getelementptr inbounds ptr, ptr [[C0]], i32 1 |
325 | 339 | // CHECK: store ptr [[T26]], ptr [[T28]] |
| 340 | + |
| 341 | +#if WITH_RESILIENCE |
| 342 | +public func requireFormallyResilientWitness<T: ResilientProto> (_ t: T) { |
| 343 | + t.impl() |
| 344 | +} |
| 345 | + |
| 346 | +// EVO: define{{.*}} swiftcc void @"$s1A27useFormallyResilientWitnessyyF"() |
| 347 | +// EVO: call swiftcc void @"$s1A31requireFormallyResilientWitnessyyx9resilient0C5ProtoRzlF"(ptr noalias %4, ptr %1, ptr @"$s9resilient15ResilientStructVyxGAA0B5ProtoAAWP") |
| 348 | +public func useFormallyResilientWitness() { |
| 349 | + requireFormallyResilientWitness(ResilientStruct(1)) |
| 350 | +} |
| 351 | +#endif |
| 352 | + |
| 353 | +#if EXPECT_CRASH |
| 354 | +protocol P { |
| 355 | + func p() |
| 356 | +} |
| 357 | + |
| 358 | +@available(SwiftStdlib 5.9, *) |
| 359 | +struct G<each T> {} |
| 360 | + |
| 361 | +@available(SwiftStdlib 5.9, *) |
| 362 | +extension G: P where repeat each T: P { |
| 363 | + func p() {} |
| 364 | +} |
| 365 | +// CRASH: not supported |
| 366 | +#endif |
0 commit comments