diff options
| author | Yong He <yonghe@outlook.com> | 2025-08-06 01:07:41 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-06 08:07:41 +0000 |
| commit | 68b0125226464cb3c9e9b7f50bfb53cda97723b4 (patch) | |
| tree | 5f0833c6d9aa759b2769f7f6ac9b3ca6ed9a10f0 /source/slang/slang-check-expr.cpp | |
| parent | 83675103a1a4fefde11b314aed26f4d37860efe7 (diff) | |
Add reflection api for overload candidate filtering. (#8066)
* Add reflection api for overload candidate filtering.
* Fix API.
* Fix.
* Update build.
* Update test.
* Update formatting.
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index f70760c5d..d2f338e65 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -354,7 +354,8 @@ DeclRefExpr* SemanticsVisitor::ConstructDeclRefExpr( // This is the bottleneck for using declarations which might be // deprecated, diagnose here. - diagnoseDeprecatedDeclRefUsage(declRef, loc, originalExpr); + if (getSink()) + diagnoseDeprecatedDeclRefUsage(declRef, loc, originalExpr); // Construct an appropriate expression based on the structured of // the declaration reference. @@ -389,7 +390,7 @@ DeclRefExpr* SemanticsVisitor::ConstructDeclRefExpr( auto expr = m_astBuilder->create<StaticMemberExpr>(); expr->loc = loc; expr->type = type; - if (!isDeclUsableAsStaticMember(declRef.getDecl())) + if (getSink() && !isDeclUsableAsStaticMember(declRef.getDecl())) { getSink()->diagnose( loc, @@ -1234,7 +1235,8 @@ Expr* SemanticsVisitor::_resolveOverloadedExprImpl( DiagnosticSink* diagSink) { auto lookupResult = overloadedExpr->lookupResult2; - SLANG_RELEASE_ASSERT(lookupResult.isValid() && lookupResult.isOverloaded()); + if (!lookupResult.isValid() || !lookupResult.isOverloaded()) + return overloadedExpr; // Take the lookup result we had, and refine it based on what is expected in context. // @@ -3827,7 +3829,7 @@ static Expr* _checkHigherOrderInvokeExpr( auto candidateExpr = actions->createHigherOrderInvokeExpr(semantics); actions->fillHigherOrderInvokeExpr(candidateExpr, semantics, lookupResultExpr); candidateExpr->loc = expr->loc; - result->candidiateExprs.add(candidateExpr); + result->candidateExprs.add(candidateExpr); } result->type.type = astBuilder->getOverloadedType(); result->loc = expr->loc; @@ -3836,12 +3838,12 @@ static Expr* _checkHigherOrderInvokeExpr( else if (auto overloadedExpr2 = as<OverloadedExpr2>(expr->baseFunction)) { OverloadedExpr2* result = astBuilder->create<OverloadedExpr2>(); - for (auto item : overloadedExpr2->candidiateExprs) + for (auto item : overloadedExpr2->candidateExprs) { auto candidateExpr = actions->createHigherOrderInvokeExpr(semantics); actions->fillHigherOrderInvokeExpr(candidateExpr, semantics, item); candidateExpr->loc = expr->loc; - result->candidiateExprs.add(candidateExpr); + result->candidateExprs.add(candidateExpr); } result->type.type = astBuilder->getOverloadedType(); result->loc = expr->loc; @@ -5181,7 +5183,7 @@ Expr* SemanticsVisitor::_lookupStaticMember(DeclRefExpr* expr, Expr* baseExpress } else if (auto overloaded2 = as<OverloadedExpr2>(baseExpression)) { - for (auto candidate : overloaded2->candidiateExprs) + for (auto candidate : overloaded2->candidateExprs) { handleLeafExpr(candidate); } |
