summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-inheritance.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp
index b44858874..cef9b6a09 100644
--- a/source/slang/slang-check-inheritance.cpp
+++ b/source/slang/slang-check-inheritance.cpp
@@ -460,6 +460,9 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
}
}
+ bool selfIsGenericParamType =
+ isDeclRefTypeOf<GenericTypeParamDeclBase>(selfType) != nullptr;
+
for (auto constraintDeclRef :
getMembersOfType<GenericTypeConstraintDecl>(astBuilder, genericDeclRef))
{
@@ -471,6 +474,13 @@ InheritanceInfo SharedSemanticsContext::_calcInheritanceInfo(
// Check only the sub-type.
visitor.CheckConstraintSubType(constraintDeclRef.getDecl()->sub);
auto sub = constraintDeclRef.getDecl()->sub;
+
+ // If the sub-type part of the generic constraint is a member expression, it can't
+ // possibly be defining a constraint for a generic type parameter, so we skip it
+ // to avoid circular checking on the generic param type.
+ if (selfIsGenericParamType && as<MemberExpr>(sub.exp))
+ continue;
+
if (!sub.type)
sub = visitor.TranslateTypeNodeForced(sub);
auto subType = constraintDeclRef.substitute(astBuilder, sub.type);