File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-Xfrontend -enable-parameterized-existential-types)
2
+ // REQUIRES: executable_test
3
+
4
+ // REQUIRES: disabled
5
+
6
+ import StdlibUnittest
7
+
8
+ var ParameterizedProtocolsTestSuite = TestSuite ( " ParameterizedProtocols " )
9
+
10
+ protocol Holder < T> {
11
+ associatedtype T
12
+ var value : T { get }
13
+ }
14
+
15
+ struct IntHolder : Holder {
16
+ var value : Int
17
+ }
18
+
19
+ struct GenericHolder < T> : Holder {
20
+ var value : T
21
+ }
22
+
23
+ ParameterizedProtocolsTestSuite . test ( " basic " ) {
24
+ let x : any Holder < Int > = IntHolder ( value: 5 )
25
+ expectEqual ( 5 , x. value)
26
+ }
27
+
28
+ func staticType< T> ( of value: inout T ) -> Any . Type {
29
+ return T . self
30
+ }
31
+
32
+ func staticTypeForHolders< T> ( of value: inout any Holder < T > ) -> Any . Type {
33
+ return ( any Holder < T > ) . self
34
+ }
35
+
36
+ ParameterizedProtocolsTestSuite . test ( " metadataEquality " ) {
37
+ var x : any Holder < Int > = IntHolder ( value: 5 )
38
+ var typeOne = staticType ( of: & x)
39
+ var typeTwo = staticTypeForHolders ( of: & x)
40
+ expectEqual ( typeOne, typeTwo)
41
+ }
42
+
43
+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments