From d5e2319c33115d0241dd9d2047c0a5f029553dde Mon Sep 17 00:00:00 2001 From: "YONGH\\yongh" Date: Thu, 2 Nov 2017 19:21:15 -0400 Subject: work inprogress --- source/slang/lookup.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/lookup.cpp') diff --git a/source/slang/lookup.cpp b/source/slang/lookup.cpp index c0cb657c4..b97dac560 100644 --- a/source/slang/lookup.cpp +++ b/source/slang/lookup.cpp @@ -453,6 +453,27 @@ void lookUpMemberImpl( } } } + else if (auto assocTypeDeclRefType = type->As()) + { + auto assocTypeDeclRef = assocTypeDeclRefType->declRef; + for (auto constraintDeclRef : getMembersOfType(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); + } + } } LookupResult lookUpMember( -- cgit v1.2.3