Skip to content

Commit f569f7d

Browse files
[Prototype] Add test for type reference from witness impl
1 parent 8ed15bd commit f569f7d

File tree

2 files changed

+76
-12
lines changed

2 files changed

+76
-12
lines changed

test/Serialization/module_summary_tables.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
// CHECK-NEXT: name: '$s6tables1CC11classMemberyyF'
1616

1717
// `protoMember` witness is recorded on the table
18-
// CHECK: witness_tables:
19-
// CHECK: 2682576275888919121: [ 767048646313834908 ]
18+
// CHECK: witness_tables:
19+
// CHECK-NEXT: 2682576275888919121:
20+
// CHECK-NEXT: - guid: 767048646313834908
21+
// CHECK-NEXT: type_guid: 16119760784751072103
2022
// `classMember` impls are recorded on the table
21-
// CHECK: vtables:
22-
// CHECK: 17602567966448237004: [ 17602567966448237004, 11756327503593502600 ]
23+
// CHECK: vtables:
24+
// CHECK: 17602567966448237004:
25+
// CHECK-NEXT: - guid: 17602567966448237004
26+
// CHECK-NEXT: type_guid: 3703703597861618193
27+
// CHECK-NEXT: - guid: 11756327503593502600
28+
// CHECK-NEXT: type_guid: 9043091933214513226
2329

2430
protocol P {
2531
func protoMember()

test/Serialization/type_refs_summary.swift

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,64 @@
66

77
// RUN: %swift-module-summary-test --to-yaml %t/type_refs.swiftmodule.summary -o %t/type_refs.summary.yaml
88

9-
// Ensure that type reference to S is recorded
9+
// Ensure that type reference to S, C and D are recorded
1010
// RUN: cat %t/type_refs.summary.yaml | %FileCheck %s -check-prefix SIMPLE-COERCE
1111

12+
// SIMPLE-COERCE: name: '$s9type_refs11coerceToAnyyypAA1DCF'
13+
// SIMPLE-COERCE-NEXT: guid: 14079990488171131
14+
// SIMPLE-COERCE-NEXT: live: false
15+
// SIMPLE-COERCE-NEXT: preserved: false
16+
// SIMPLE-COERCE-NEXT: calls: []
17+
// SIMPLE-COERCE-NEXT: type_refs:
18+
// SIMPLE-COERCE-NEXT: - name: 9type_refs1DC
19+
// SIMPLE-COERCE-NEXT: guid: 1332210649212571009
20+
21+
// SIMPLE-COERCE: name: '$s9type_refs11coerceToAnyyypAA1CCF'
22+
// SIMPLE-COERCE-NEXT: guid: 1940219073901329473
23+
// SIMPLE-COERCE-NEXT: live: false
24+
// SIMPLE-COERCE-NEXT: preserved: false
25+
// SIMPLE-COERCE-NEXT: calls: []
26+
// SIMPLE-COERCE-NEXT: type_refs:
27+
// SIMPLE-COERCE-NEXT: - name: 9type_refs1CC
28+
// SIMPLE-COERCE-NEXT: guid: 14053292587484144632
29+
1230
// SIMPLE-COERCE: name: '$s9type_refs9coerceToPyAA1P_pAA1SVF'
13-
// SIMPLE-COERCE-NEXT: guid: 15452386893050095333
14-
// SIMPLE-COERCE-NEXT: live: false
15-
// SIMPLE-COERCE-NEXT: preserved: false
16-
// SIMPLE-COERCE-NEXT: calls: []
17-
// SIMPLE-COERCE-NEXT: type_refs:
18-
// SIMPLE-COERCE-NEXT: - name: 9type_refs1SV
19-
// SIMPLE-COERCE-NEXT: guid: 12736589225588998764
31+
// SIMPLE-COERCE-NEXT: guid: 15452386893050095333
32+
// SIMPLE-COERCE-NEXT: live: false
33+
// SIMPLE-COERCE-NEXT: preserved: false
34+
// SIMPLE-COERCE-NEXT: calls: []
35+
// SIMPLE-COERCE-NEXT: type_refs:
36+
// SIMPLE-COERCE-NEXT: - name: 9type_refs1SV
37+
// SIMPLE-COERCE-NEXT: guid: 12736589225588998764
38+
39+
40+
41+
// Ensure that witness impl of S.foo for P has type ref to S
42+
// RUN: cat %t/type_refs.summary.yaml | %FileCheck %s -check-prefix WITNESS-IMPL
43+
44+
// WITNESS-IMPL: 12925277474523063582:
45+
// WITNESS-IMPL-NEXT: name: '$s9type_refs1SVAA1PA2aDP3fooyyFTW'
46+
47+
// WITNESS-IMPL: witness_tables:
48+
// WITNESS-IMPL-NEXT: 17891631795932606560:
49+
// WITNESS-IMPL-NEXT: - guid: 12925277474523063582
50+
// WITNESS-IMPL-NEXT: type_guid: 12736589225588998764
51+
52+
53+
// Ensure that vtable impl of C.bar and D.bar have type ref to C
54+
// RUN: cat %t/type_refs.summary.yaml | %FileCheck %s -check-prefix WITNESS-IMPL
55+
56+
57+
// VTABLE-IMPL: 14897920476774525675:
58+
// VTABLE-IMPL-NEXT: name: '$s9type_refs1CC3baryyF'
59+
// VTABLE-IMPL: 16977749031506698911:
60+
// VTABLE-IMPL-NEXT: name: '$s9type_refs1DC3baryyF'
61+
62+
// VTABLE-IMPL: 14897920476774525675:
63+
// VTABLE-IMPL-NEXT: - guid: 14897920476774525675
64+
// VTABLE-IMPL-NEXT: type_guid: 14053292587484144632
65+
// VTABLE-IMPL-NEXT: - guid: 16977749031506698911
66+
// VTABLE-IMPL-NEXT: type_guid: 1332210649212571009
2067

2168

2269
// RUN: %swift_frontend_plain -cross-module-opt %t/type_refs.swiftmodule.summary -module-summary-embed-debug-name -o %t/type_refs.swiftmodule.merged-summary
@@ -38,6 +85,17 @@ struct V : P {
3885
func foo() {}
3986
}
4087

88+
class C {
89+
func bar() {}
90+
}
91+
92+
class D : C {
93+
override func bar() {}
94+
}
95+
4196
func coerceToP(_ x: S) -> P { return x }
4297

4398
_ = coerceToP(S())
99+
100+
func coerceToAny(_ x: C) -> Any { return x }
101+
func coerceToAny(_ x: D) -> Any { return x }

0 commit comments

Comments
 (0)