summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-08-24 12:05:19 -0700
committerGitHub <noreply@github.com>2022-08-24 12:05:19 -0700
commitba6f55ed9481960b4f6c7f0a6b8f1cf7d450c752 (patch)
treebd92bf3cca5614585f8be6ad6f57510b18565b47 /source/slang/slang-check-expr.cpp
parent3746a47ce407b14c4afbfc5b625513cf81b5e890 (diff)
Allow `static const` interface requirements. (#2378)
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 8e14af72a..e33d26c0c 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -982,7 +982,7 @@ namespace Slang
|| opName == getName("|") || opName == getName("&") || opName == getName("^") || opName == getName("~") || opName == getName("%") ||
opName == getName("?:") || opName == getName("<<") || opName == getName(">>"))
{
- auto result = m_astBuilder->create<SomeIntVal>();
+ auto result = m_astBuilder->create<FuncCallIntVal>();
result->args.addRange(argVals, argCount);
result->funcDeclRef = funcDeclRef;
result->funcType = as<Type>(funcDeclRefExpr.getExpr()->type->substitute(
@@ -1131,6 +1131,22 @@ namespace Slang
if(!decl->hasModifier<ConstModifier>())
return nullptr;
+ if (isInterfaceRequirement(decl))
+ {
+ for (auto subst = declRef.substitutions.substitutions; subst; subst = subst->outer)
+ {
+ if (auto thisTypeSubst = as<ThisTypeSubstitution>(subst))
+ {
+ auto val = WitnessLookupIntVal::tryFold(
+ m_astBuilder,
+ thisTypeSubst->witness,
+ decl,
+ declRef.substitute(m_astBuilder, decl->type.type));
+ return as<IntVal>(val);
+ }
+ }
+ }
+
auto initExpr = getInitExpr(m_astBuilder, declRef);
if(!initExpr)
return nullptr;