From 7764b83d24d341334ca7c1693cae2472be8f8d99 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 10 Jul 2025 21:11:46 -0700 Subject: Fix issue in match parameter type that depend on an associatedtype. (#7707) --- .../interfaces/assoctype-param.slang | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/language-feature/interfaces/assoctype-param.slang (limited to 'tests/language-feature') diff --git a/tests/language-feature/interfaces/assoctype-param.slang b/tests/language-feature/interfaces/assoctype-param.slang new file mode 100644 index 000000000..f2572484e --- /dev/null +++ b/tests/language-feature/interfaces/assoctype-param.slang @@ -0,0 +1,32 @@ +//TEST:INTERPRET(filecheck=CHECK): + +public interface IDataTrait { + public associatedtype InputType; + public static const int32_t kElementCount; +} + +public struct DataTrait0 : IDataTrait { + public typedef float InputType; + public static const int32_t kElementCount = 2; +} + +public interface IGenericInterface { + public Array eval(const Di.InputType interface_input); +} + +public struct GenericImpl : IGenericInterface +{ + public Array eval( + const Dx.InputType impl_input) + { + return makeArrayFromElement(impl_input); + } +} + +void main() +{ + GenericImpl f; + let rs = f.eval(1.0); + printf("result is %f\n", rs[0]); + // CHECK: result is 1.0 +} -- cgit v1.2.3