diff options
| author | Yong He <yonghe@outlook.com> | 2025-07-10 21:11:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-11 04:11:46 +0000 |
| commit | 7764b83d24d341334ca7c1693cae2472be8f8d99 (patch) | |
| tree | 50ed4779a43bbe52798340c67c5d83bb30ba792b /tests/language-feature | |
| parent | 0ddb2fcbbaa5387990c8812341fbe8e2848f8989 (diff) | |
Fix issue in match parameter type that depend on an associatedtype. (#7707)
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/interfaces/assoctype-param.slang | 32 |
1 files changed, 32 insertions, 0 deletions
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<Ti : IFloat> { + public Array<Di.InputType, Di.kElementCount> eval<Di : IDataTrait>(const Di.InputType interface_input); +} + +public struct GenericImpl<T : IFloat> : IGenericInterface<T> +{ + public Array<Dx.InputType, Dx.kElementCount> eval<Dx : IDataTrait>( + const Dx.InputType impl_input) + { + return makeArrayFromElement<Dx.InputType, Dx.kElementCount>(impl_input); + } +} + +void main() +{ + GenericImpl<float> f; + let rs = f.eval<DataTrait0>(1.0); + printf("result is %f\n", rs[0]); + // CHECK: result is 1.0 +} |
