diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-04 15:20:21 -0400 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-04 15:20:21 -0400 |
| commit | 31e7f84484d227206f3bbb33a8b9be8a9acecfe5 (patch) | |
| tree | eb06912348d3fd39a671308d80db999d144ae024 /source/slang/lookup.cpp | |
| parent | d803bf74eee7842ce8a358e145b2546c03308dfc (diff) | |
Passing both assoctype-simple and assoctype-complex test cases.
Diffstat (limited to 'source/slang/lookup.cpp')
| -rw-r--r-- | source/slang/lookup.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/source/slang/lookup.cpp b/source/slang/lookup.cpp index a5425074f..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,26 +472,7 @@ void lookUpMemberImpl( lookUpMemberImpl(session, semantics, name, bound, ioResult, &breadcrumb); } } - else 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); - } - } + } } |
