blob: 9f86ca7dc8cb680a94c0621d59fe83a43d44f032 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
// Test that we can use `where` clause to constrain an associatedtype.
interface IBar
{
associatedtype TB;
TB get();
}
interface IFoo
{
associatedtype TA : IBar where TA.TB == int;
TA getVal();
}
struct BarImpl : IBar
{
typealias TB = int;
int x;
int get() { return x; }
}
struct FooImpl : IFoo
{
typealias TA = BarImpl;
TA getVal() { TA a; a.x = 1; return a; }
}
int helper<T : IFoo>(T foo)
{
// foo.getVal().get() has type `T.TA.TB`,
// because there is a type equality constraint defined on
// `IFoo.TA` such that `IFoo::TA.TB == int`, we should be able
// to conclude that `T.TA.TB` is `int` and the `return` here
// should type check.
return foo.getVal().get();
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;
[numthreads(1,1,1)]
void computeMain()
{
FooImpl foo;
outputBuffer[0] = helper(foo);
// CHECK: 1.0
}
|