From 83876733d69582eec6bad26af64a651d40fa43aa Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 21 Mar 2023 20:03:12 -0700 Subject: Fix associated type resolution bug. (#2719) * Fix associated type resolution bug. * Fix. * Fix language server hinting messed up by breadcrumb nodes. --------- Co-authored-by: Yong He --- source/slang/slang-syntax.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'source/slang/slang-syntax.cpp') diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index 470f5f983..27aba435f 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -1234,23 +1234,32 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt } // Hard code implementation of T.Differential.Differential == T.Differential rule. - if (auto builtinReq = substDeclRef.getDecl()->findModifier()) + auto foldResult = [&]() -> Val* { - if (builtinReq->kind == BuiltinRequirementKind::DifferentialType) + auto builtinReq = substDeclRef.getDecl()->findModifier(); + if (!builtinReq) + return nullptr; + if (builtinReq->kind != BuiltinRequirementKind::DifferentialType) + return nullptr; + // Is the concrete type a Differential associated type? + auto innerDeclRefType = as(thisSubst->witness->sub); + if (!innerDeclRefType) + return nullptr; + auto innerBuiltinReq = innerDeclRefType->declRef.decl->findModifier(); + if (!innerBuiltinReq) + return nullptr; + if (innerBuiltinReq->kind != BuiltinRequirementKind::DifferentialType) + return nullptr; + if (!innerDeclRefType->declRef.equals(declRef)) { - // Is the concrete type a Differential associated type? - if (auto innerDeclRefType = as(thisSubst->witness->sub)) - { - if (auto innerBuiltinReq = innerDeclRefType->declRef.decl->findModifier()) - { - if (innerBuiltinReq->kind == BuiltinRequirementKind::DifferentialType) - { - return innerDeclRefType; - } - } - } + auto result = _tryLookupConcreteAssociatedTypeFromThisTypeSubst(builder, innerDeclRefType->declRef); + if (result) + return result; } - } + return innerDeclRefType; + }(); + if (foldResult) + return foldResult; } } } -- cgit v1.2.3