summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/higher-order-functions/inference.slang
blob: 3468395d79498f4b86223ce07485efd7f3980d50 (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
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj

//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(uint tig : SV_GroupIndex)
{
    // Test that we infer the type parameters to X from the type of f
    x(f);
    // Testthat we infer the type paramters to from a specialized generic (g)
    y(g<int>);
    outputBuffer[tig] = p;
}

static int p = 0;

func x<A, B>(f : functype (A) -> B)
{
    ++p;
}

float f(int)
{
    return 1;
}

func y<A, B, C>(g : functype (A, B) -> C)
{
    p += 2;
}

void g<A>(A, bool)
{ }