summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/slang-check-decl.cpp2
-rw-r--r--tests/language-feature/interfaces/assoctype-param.slang32
2 files changed, 33 insertions, 1 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 847f296bb..7cd1d7df8 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -4407,7 +4407,7 @@ bool SemanticsVisitor::doesGenericSignatureMatchRequirement(
auto satisfyingWitness = m_astBuilder->getDeclaredSubtypeWitness(
getSub(m_astBuilder, satisfyingConstraintDeclRef),
getSup(m_astBuilder, satisfyingConstraintDeclRef),
- satisfyingConstraintDeclRef);
+ satisfyingConstraintDeclRef.getDecl());
requiredSubstArgs.add(satisfyingWitness);
}
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
+}