Skip to content

Commit a1ea56b

Browse files
committed
Add test case for https://bugs.swift.org/browse/SR-8643 which is now fixed
1 parent c906c18 commit a1ea56b

File tree

5 files changed

+59
-36
lines changed

5 files changed

+59
-36
lines changed

test/SILGen/Inputs/keypaths_multi_file_b.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,24 @@ struct A {
99
set {}
1010
}
1111
}
12+
13+
final class C<T> {
14+
var a = 0
15+
var b = 0
16+
17+
subscript(x: Int) -> Int { return x }
18+
}
19+
20+
class D<T> {
21+
var a = 0
22+
var b = 0
23+
24+
subscript(x: Int) -> Int { return x }
25+
}
26+
27+
protocol P {
28+
var a: Int { get set }
29+
var b: Int { get set }
30+
31+
subscript(x: Int) -> Int { get set }
32+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public protocol PP {}
2+
public protocol QQ {}
3+
4+
public class AA : PP {}
5+
public class BB : AA {}
6+
7+
public struct DD<T: PP> {}
8+
9+
public struct CC<T: PP> {
10+
public var x: DD<T> { fatalError("death") }
11+
}

test/SILGen/keypaths_multi_file.swift

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
// RUN: %target-swift-emit-silgen -module-name keypaths -primary-file %s %S/Inputs/keypaths_multi_file_b.swift | %FileCheck %s
2-
// RUN: %target-swift-emit-silgen -module-name keypaths %s -primary-file %S/Inputs/keypaths_multi_file_b.swift | %FileCheck --check-prefix=DEFINITION %s
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-build-swift -module-name keypaths_resilient -emit-module -Xfrontend -enable-key-path-resilience %S/Inputs/keypaths_multi_file_c.swift -emit-module-path %t/keypaths_resilient.swiftmodule
4+
5+
// RUN: %target-swift-emit-silgen -module-name keypaths -primary-file %s %S/Inputs/keypaths_multi_file_b.swift -I %t | %FileCheck %s
6+
// RUN: %target-swift-emit-silgen -module-name keypaths %s -primary-file %S/Inputs/keypaths_multi_file_b.swift -I %t | %FileCheck --check-prefix=DEFINITION %s
7+
8+
import keypaths_resilient
39

410
func foo(x: Int) -> KeyPath<A, Int> {
511
switch x {
@@ -18,3 +24,22 @@ func foo(x: Int) -> KeyPath<A, Int> {
1824
// A.subscript setter
1925
// CHECK-LABEL: sil hidden_external @$S8keypaths1AVyS2icis
2026
// DEFINITION-LABEL: sil hidden @$S8keypaths1AVyS2icis
27+
28+
func bar<T>(_: T) {
29+
_ = \C<T>.b
30+
_ = \C<T>[0]
31+
32+
_ = \D<T>.b
33+
_ = \D<T>[0]
34+
35+
_ = \P.b
36+
37+
// FIXME: crashes
38+
// _ = \P[0]
39+
}
40+
41+
// https://bugs.swift.org/browse/SR-8643
42+
class MM<T: P> : PP {}
43+
func foo<T3: BB, T4: MM<T3>>(t: T3, u: T4) {
44+
let _ = \CC<T4>.x
45+
}

test/multifile/Inputs/keypath.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/multifile/keypath.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)