summaryrefslogtreecommitdiff
path: root/source/slang/lookup.cpp
diff options
context:
space:
mode:
authorYONGH\yongh <yonghe@outlook.com>2017-11-02 19:21:15 -0400
committerYONGH\yongh <yonghe@outlook.com>2017-11-02 19:21:15 -0400
commitd5e2319c33115d0241dd9d2047c0a5f029553dde (patch)
treeb89aef27f2330e7c568b0f799f0902015fdd4f18 /source/slang/lookup.cpp
parente2b97607977977fd2dbe298c2bb4512f4715dd4c (diff)
work inprogress
Diffstat (limited to 'source/slang/lookup.cpp')
-rw-r--r--source/slang/lookup.cpp21
1 files changed, 21 insertions, 0 deletions
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<AssocTypeDeclRefType>())
+ {
+ auto assocTypeDeclRef = assocTypeDeclRefType->declRef;
+ 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);
+ }
+ }
}
LookupResult lookUpMember(