From a8471a1d9a5591202bf4a552aa7d1bf11088fdce Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 31 Dec 2024 09:52:51 -0800 Subject: Fix `getInheritanceInfo` for `ExtractExistentialType`. (#5971) --- source/slang/slang-syntax.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-syntax.cpp') diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index 5dc6ca695..6fdd5088a 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -701,11 +701,18 @@ Type* DeclRefType::create(ASTBuilder* astBuilder, DeclRef declRef) } return declRefType; } - else if (as(declRef.getDecl()) && as(declRef.declRefBase)) + else if (as(declRef.getDecl())) { - declRef = createDefaultSubstitutionsIfNeeded(astBuilder, nullptr, declRef); + if (as(declRef.declRefBase)) + { + declRef = createDefaultSubstitutionsIfNeeded(astBuilder, nullptr, declRef); - return astBuilder->getOrCreate(declRef.declRefBase); + return astBuilder->getOrCreate(declRef.declRefBase); + } + else if (auto lookupDeclRef = as(declRef.declRefBase)) + { + return lookupDeclRef->getWitness()->getSub(); + } } else if (auto typedefDecl = as(declRef.getDecl())) { @@ -714,12 +721,9 @@ Type* DeclRefType::create(ASTBuilder* astBuilder, DeclRef declRef) typedefDecl->type.type->substitute(astBuilder, SubstitutionSet(declRef))); return astBuilder->getErrorType(); } - else - { - declRef = createDefaultSubstitutionsIfNeeded(astBuilder, nullptr, declRef); - return astBuilder->getOrCreate(declRef.declRefBase); - } + declRef = createDefaultSubstitutionsIfNeeded(astBuilder, nullptr, declRef); + return astBuilder->getOrCreate(declRef.declRefBase); } // -- cgit v1.2.3