diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-13 15:17:43 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2018-01-13 15:17:43 -0500 |
| commit | 4d2086f47e25aa4545df95ddfd260c8bc5aafdb2 (patch) | |
| tree | 10c92df406a82e7a5eb24b56c17d9256a7183c44 /source | |
| parent | 99f49e42fd3d55b0404261379d68dcca2b350209 (diff) | |
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.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/check.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 57ed71cb6..6c484b493 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -155,8 +155,6 @@ namespace Slang RefPtr<Expr> baseExpr, SourceLoc loc) { - if (declRef.As<AssocTypeDecl>()) - getNewThisTypeSubst(declRef); if (baseExpr) { RefPtr<Expr> expr; @@ -6993,15 +6991,19 @@ namespace Slang Decl* decl, SubstitutionSet parentSubst) { + SubstitutionSet resultSubst = parentSubst; + if (auto interfaceDecl = dynamic_cast<InterfaceDecl*>(decl)) + { + resultSubst.thisTypeSubstitution = new ThisTypeSubstitution(); + } auto dd = decl->ParentDecl; if( auto genericDecl = dynamic_cast<GenericDecl*>(dd) ) { // We don't want to specialize references to anything // other than the "inner" declaration itself. if(decl != genericDecl->inner) - return parentSubst; + return resultSubst; - SubstitutionSet resultSubst = parentSubst; RefPtr<GenericSubstitution> subst = new GenericSubstitution(); subst->genericDecl = genericDecl; subst->outer = parentSubst.genericSubstitutions; @@ -7032,9 +7034,8 @@ namespace Slang subst->args.Add(witness); } } - return resultSubst; } - return parentSubst; + return resultSubst; } SubstitutionSet createDefaultSubstitutions( |
