From a6fcb3b0ed2b185723afde750bd4491b5b4113eb Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 20 Sep 2022 21:32:32 -0700 Subject: Fix regression in check-overload. (#2407) * Fix regression in check-overload. * Make sure language server supports partiallyAppliedGenericExpr. Co-authored-by: Yong He --- source/slang/slang-ast-expr.h | 2 ++ source/slang/slang-ast-iterator.h | 4 ++++ source/slang/slang-check-overload.cpp | 7 +++++-- source/slang/slang-language-server-ast-lookup.cpp | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/slang/slang-ast-expr.h b/source/slang/slang-ast-expr.h index 1e4440042..13d687da0 100644 --- a/source/slang/slang-ast-expr.h +++ b/source/slang/slang-ast-expr.h @@ -494,6 +494,8 @@ class PartiallyAppliedGenericExpr : public Expr SLANG_AST_CLASS(PartiallyAppliedGenericExpr); public: + Expr* originalExpr = nullptr; + /// The generic being applied DeclRef baseGenericDeclRef; diff --git a/source/slang/slang-ast-iterator.h b/source/slang/slang-ast-iterator.h index 4d37b68e7..a145d759b 100644 --- a/source/slang/slang-ast-iterator.h +++ b/source/slang/slang-ast-iterator.h @@ -258,6 +258,10 @@ struct ASTIterator dispatchIfNotNull(expr->value); dispatchIfNotNull(expr->typeExpr); } + void visitPartiallyAppliedGenericExpr(PartiallyAppliedGenericExpr* expr) + { + dispatchIfNotNull(expr->originalExpr); + } }; struct ASTIteratorStmtVisitor : public StmtVisitor diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 57c9c1199..7dba3986a 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -729,7 +729,7 @@ namespace Slang { auto expr = m_astBuilder->create(); expr->loc = context.loc; - + expr->originalExpr = originalAppExpr; expr->baseGenericDeclRef = as(baseExpr)->declRef.as(); expr->substWithKnownGenericArgs = (GenericSubstitution*)candidate.subst; return expr; @@ -1418,7 +1418,10 @@ namespace Slang } else if (auto genericDeclRef = item.declRef.as()) { - addOverloadCandidatesForCallToGeneric(LookupResultItem(genericDeclRef), context); + LookupResultItem innerItem; + innerItem.breadcrumbs = item.breadcrumbs; + innerItem.declRef = genericDeclRef; + addOverloadCandidatesForCallToGeneric(innerItem, context); } else if( auto typeDefDeclRef = item.declRef.as() ) { diff --git a/source/slang/slang-language-server-ast-lookup.cpp b/source/slang/slang-language-server-ast-lookup.cpp index 9a42f86f3..a44c7a7d9 100644 --- a/source/slang/slang-language-server-ast-lookup.cpp +++ b/source/slang/slang-language-server-ast-lookup.cpp @@ -402,6 +402,10 @@ public: return true; return dispatchIfNotNull(expr->value); } + bool visitPartiallyAppliedGenericExpr(PartiallyAppliedGenericExpr* expr) + { + return dispatchIfNotNull(expr->originalExpr); + } bool visitModifiedTypeExpr(ModifiedTypeExpr* expr) { return dispatchIfNotNull(expr->base.exp); } bool visitTryExpr(TryExpr* expr) { return dispatchIfNotNull(expr->base); } -- cgit v1.2.3