summaryrefslogtreecommitdiffstats
path: root/source/slang/lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/lookup.cpp')
-rw-r--r--source/slang/lookup.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/slang/lookup.cpp b/source/slang/lookup.cpp
index c0cb657c4..b01732362 100644
--- a/source/slang/lookup.cpp
+++ b/source/slang/lookup.cpp
@@ -410,7 +410,27 @@ void lookUpMemberImpl(
if (auto declRefType = type->As<DeclRefType>())
{
auto declRef = declRefType->declRef;
- if (auto aggTypeDeclRef = declRef.As<AggTypeDecl>())
+ if (auto assocTypeDeclRef = declRef.As<AssocTypeDecl>())
+ {
+ for (auto constraintDeclRef : getMembersOfType<GenericTypeConstraintDecl>(assocTypeDeclRef))
+ {
+ // The super-type in the constraint (e.g., `Foo` in `T : Foo`)
+ // will tell us a type we should use for lookup.
+ auto bound = GetSup(constraintDeclRef);
+
+ // Go ahead and use the target type, with an appropriate breadcrumb
+ // to indicate that we indirected through a type constraint.
+
+ BreadcrumbInfo breadcrumb;
+ breadcrumb.prev = inBreadcrumbs;
+ breadcrumb.kind = LookupResultItem::Breadcrumb::Kind::Constraint;
+ breadcrumb.declRef = constraintDeclRef;
+
+ // TODO: Need to consider case where this might recurse infinitely.
+ lookUpMemberImpl(session, semantics, name, bound, ioResult, &breadcrumb);
+ }
+ }
+ else if (auto aggTypeDeclRef = declRef.As<AggTypeDecl>())
{
LookupRequest request;
request.semantics = semantics;
@@ -452,7 +472,9 @@ void lookUpMemberImpl(
lookUpMemberImpl(session, semantics, name, bound, ioResult, &breadcrumb);
}
}
+
}
+
}
LookupResult lookUpMember(