Skip to content

Commit 4d2086f

Browse files
committed
Fix creation of ThisTypeSubstitution.
`createDefaultSubstitutions` now responsible for creating a `ThisTypeSubstitution` when `decl` is an `InterfaceDecl`. This is to ensure a reference to an associated type decl from the same interface that defines the assoctype decl will get a `ThisTypeSubstitution` so that the right hand side of it can be replaced by future substitutions.
1 parent 99f49e4 commit 4d2086f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

source/slang/check.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ namespace Slang
155155
RefPtr<Expr> baseExpr,
156156
SourceLoc loc)
157157
{
158-
if (declRef.As<AssocTypeDecl>())
159-
getNewThisTypeSubst(declRef);
160158
if (baseExpr)
161159
{
162160
RefPtr<Expr> expr;
@@ -6993,15 +6991,19 @@ namespace Slang
69936991
Decl* decl,
69946992
SubstitutionSet parentSubst)
69956993
{
6994+
SubstitutionSet resultSubst = parentSubst;
6995+
if (auto interfaceDecl = dynamic_cast<InterfaceDecl*>(decl))
6996+
{
6997+
resultSubst.thisTypeSubstitution = new ThisTypeSubstitution();
6998+
}
69966999
auto dd = decl->ParentDecl;
69977000
if( auto genericDecl = dynamic_cast<GenericDecl*>(dd) )
69987001
{
69997002
// We don't want to specialize references to anything
70007003
// other than the "inner" declaration itself.
70017004
if(decl != genericDecl->inner)
7002-
return parentSubst;
7005+
return resultSubst;
70037006

7004-
SubstitutionSet resultSubst = parentSubst;
70057007
RefPtr<GenericSubstitution> subst = new GenericSubstitution();
70067008
subst->genericDecl = genericDecl;
70077009
subst->outer = parentSubst.genericSubstitutions;
@@ -7032,9 +7034,8 @@ namespace Slang
70327034
subst->args.Add(witness);
70337035
}
70347036
}
7035-
return resultSubst;
70367037
}
7037-
return parentSubst;
7038+
return resultSubst;
70387039
}
70397040

70407041
SubstitutionSet createDefaultSubstitutions(

0 commit comments

Comments
 (0)