summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-syntax.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-syntax.cpp')
-rw-r--r--source/slang/slang-syntax.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp
index 9a7200e9d..5b4b61849 100644
--- a/source/slang/slang-syntax.cpp
+++ b/source/slang/slang-syntax.cpp
@@ -838,28 +838,40 @@ Index getFilterCountImpl(const ReflectClassInfo& clsInfo, MemberFilterStyle filt
// Otherwise, check if we are trying to apply
// a this-type substitution to the given interface
//
- for(auto s = substsToApply; s; s = s->outer)
+ // Note: We want to skip the ThisTypeSubstitution that specializes
+ // declToSpecialize itself (when declToSpecialize is an interface
+ // decl and the subst specializes it), and only pull the
+ // ThisTypeSubstitution when the decl is referencing a child of
+ // the interface decl being specialized. This is because
+ // by default an interface declref type is a "free" existential
+ // type that shouldn't be specialized by someone else, unless
+ // there is an "implicit" ThisType reference preceeding a child
+ // reference.
+ if (declToSpecialize != ancestorInterfaceDecl)
{
- auto appThisTypeSubst = as<ThisTypeSubstitution>(s);
- if(!appThisTypeSubst)
- continue;
+ for (auto s = substsToApply; s; s = s->outer)
+ {
+ auto appThisTypeSubst = as<ThisTypeSubstitution>(s);
+ if (!appThisTypeSubst)
+ continue;
- if(appThisTypeSubst->interfaceDecl != ancestorInterfaceDecl)
- continue;
+ if (appThisTypeSubst->interfaceDecl != ancestorInterfaceDecl)
+ continue;
- int diff = 0;
- auto restSubst = specializeSubstitutions(
- astBuilder,
- ancestorInterfaceDecl->parentDecl,
- substsToSpecialize,
- substsToApply,
- &diff);
+ int diff = 0;
+ auto restSubst = specializeSubstitutions(
+ astBuilder,
+ ancestorInterfaceDecl->parentDecl,
+ substsToSpecialize,
+ substsToApply,
+ &diff);
- ThisTypeSubstitution* firstSubst = astBuilder->getOrCreateThisTypeSubstitution(
- ancestorInterfaceDecl, appThisTypeSubst->witness, restSubst);
+ ThisTypeSubstitution* firstSubst = astBuilder->getOrCreateThisTypeSubstitution(
+ ancestorInterfaceDecl, appThisTypeSubst->witness, restSubst);
- (*ioDiff)++;
- return firstSubst;
+ (*ioDiff)++;
+ return firstSubst;
+ }
}
}
}