From 4d2086f47e25aa4545df95ddfd260c8bc5aafdb2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 13 Jan 2018 15:17:43 -0500 Subject: 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. --- source/slang/check.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source') 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 baseExpr, SourceLoc loc) { - if (declRef.As()) - getNewThisTypeSubst(declRef); if (baseExpr) { RefPtr expr; @@ -6993,15 +6991,19 @@ namespace Slang Decl* decl, SubstitutionSet parentSubst) { + SubstitutionSet resultSubst = parentSubst; + if (auto interfaceDecl = dynamic_cast(decl)) + { + resultSubst.thisTypeSubstitution = new ThisTypeSubstitution(); + } auto dd = decl->ParentDecl; if( auto genericDecl = dynamic_cast(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 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( -- cgit v1.2.3