diff options
| author | Yong He <yonghe@outlook.com> | 2024-10-01 09:34:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-01 09:34:31 -0700 |
| commit | 7ce7bb3364cf84f5a9247358dcec79ba5aef8572 (patch) | |
| tree | 440f41317666c4fcd2f036c5ae7575f98e8f6de9 /tests/language-feature | |
| parent | c6427e36b31df41c6415570f4e8277f56e265c2a (diff) | |
Fix crash when compiling associatedtypes with generic interface constraints. (#5200)
* Fix crash when compiling associatedtypes with generic interface constraints.
* delete hlsl.meta.slang.temp.h.
* Fix.
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/generics/generic-assoc-type-constraint.slang | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/language-feature/generics/generic-assoc-type-constraint.slang b/tests/language-feature/generics/generic-assoc-type-constraint.slang new file mode 100644 index 000000000..6b9aa1b01 --- /dev/null +++ b/tests/language-feature/generics/generic-assoc-type-constraint.slang @@ -0,0 +1,44 @@ +//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 an associated type can be constrained to a generic interface. + + +interface IB<let DIM : int> +{ + int bar(); +} + +interface IA<let DIM : int> +{ + associatedtype B : IB<DIM>; + B getB(); +} + +struct BImpl<int x> : IB<x> +{ + int bar() { return x; } +} + +struct AImpl<int y> : IA<y> +{ + typealias B = BImpl<y>; + B getB() { BImpl<y> b = {}; return b; } +} + +int test<int z, T : IA<z>>(T t) +{ + T.B bb = t.getB(); + return bb.bar(); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + AImpl<5> a; + // CHECK: 5 + outputBuffer[0] = test(a); +}
\ No newline at end of file |
