summaryrefslogtreecommitdiff
path: root/tests/language-feature/interfaces/generic-requirement-synth-2.slang
blob: 9066fc5b771fcd2c96280a8b3fb7bb46b27298f9 (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
// Test that we allow type conformances whose base interface is generic.

//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-dx11 -compute  -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute  -output-using-type

interface IStack<let D : int>
{
    IStack<D - N> popN<let N : int>();

    int get();
}
struct StackImpl<let D : int> : IStack<D>
{
    // member 'popN' does not match interface requirement.
    StackImpl<D - N> popN<int N>() { return StackImpl<D - N>(); }

    int get() { return D; }
}

int helper<int n, T : IStack<n>>(T stack)
{
    return stack.popN<2>().get();
}

//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4);
RWStructuredBuffer<int> outputBuffer;

[numthreads(1, 1, 1)]
void computeMain()
{
    StackImpl<5> obj = StackImpl<5>();

    // CHECK: 3
    outputBuffer[0] = helper(obj);
}