summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index 855bde6a6..52b3e64d4 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -4744,6 +4744,28 @@ struct ExprLoweringVisitorBase : public ExprVisitor<Derived, LoweredValInfo>
// sense to specialize a key.
return extractField(superType, value, declaredSubtypeWitness->getDeclRef().getDecl());
}
+ else if (auto transitiveSubtypeWitness = as<TransitiveSubtypeWitness>(subTypeWitness))
+ {
+ // Try to resolve the inheritance situation which may show-up with 2+ levels of inheritance.
+ // We will recursivly follow through the subType->midType & midType->superType witnesses until
+ // we resolve DeclaredSubtypeWitness's
+ LoweredValInfo subToMid;
+ if (auto witness = as<SubtypeWitness>(transitiveSubtypeWitness->getSubToMid()))
+ subToMid = emitCastToConcreteSuperTypeRec(value, lowerType(context, witness->getSup()), witness);
+ else
+ {
+ SLANG_ASSERT(!"unhandled");
+ return nullptr;
+ }
+
+ if (auto witness = as<SubtypeWitness>(transitiveSubtypeWitness->getMidToSup()))
+ return emitCastToConcreteSuperTypeRec(subToMid, superType, witness);
+ else
+ {
+ SLANG_ASSERT(!"unhandled");
+ return nullptr;
+ }
+ }
else
{
SLANG_ASSERT(!"unhandled");