Skip to content

Commit 5783b0c

Browse files
committed
Add a testcase to verify basic execution for constrained existentials
Disabled for now; there's apparently a bug.
1 parent 02c2246 commit 5783b0c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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()

0 commit comments

Comments
 (0)