From cf66563cfdcff9b7d76017e5b73319705ccdb735 Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Tue, 28 Jan 2025 21:24:35 -0500 Subject: Fix exact-match witness synthesis for static functions (#6204) * fix non-static methods when trying to synthesize method requirement witness * add tests * update test * improve test --------- Co-authored-by: Yong He --- .../non-static-method-implemented-by-static.slang | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/language-feature/interfaces/non-static-method-implemented-by-static.slang (limited to 'tests/language-feature/interfaces/non-static-method-implemented-by-static.slang') diff --git a/tests/language-feature/interfaces/non-static-method-implemented-by-static.slang b/tests/language-feature/interfaces/non-static-method-implemented-by-static.slang new file mode 100644 index 000000000..9c243af94 --- /dev/null +++ b/tests/language-feature/interfaces/non-static-method-implemented-by-static.slang @@ -0,0 +1,45 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute -output-using-type + +//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0 0], stride=4); +RWStructuredBuffer outputBuffer; + +interface Base +{ + int getValue(); + int getValue(float a); +} + +struct Impl1 : Base +{ + // This is static and allowed to implement interface's non-static method. + static int getValue() { return 5; } + int getValue(float a) { return int(a) + 5; } +} + +struct Impl2 : Base +{ + // This is static with one default parameter and allowed to implement interface's non-static method. + static int getValue(int a = 3) { return a + 5; } + int getValue(float a) { return int(a) + 5; } +} + +int callGet(T t) +{ + return t.getValue(); +} + +[numthreads(1, 1, 1)] +void computeMain() +{ + Impl1 impl1; + Impl2 impl2; + + uint index = 0; + + outputBuffer[index++] = Impl1::getValue(); + outputBuffer[index++] = callGet(impl1); + + outputBuffer[index++] = Impl2::getValue(); + outputBuffer[index++] = callGet(impl2); + outputBuffer[index++] = impl2.getValue(5); +} -- cgit v1.2.3