summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/lower-to-ir.cpp')
-rw-r--r--source/slang/lower-to-ir.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index 61ca53278..498783f4b 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -2788,19 +2788,30 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo>
// TODO: if this inheritance declaration is under an extension,
// then we should construct the type that is being extended,
// and not a reference to the extension itself.
- auto parentDecl = inheritanceDecl->ParentDecl;
- RefPtr<Type> type = DeclRefType::Create(
- context->getSession(),
- makeDeclRef(parentDecl));
+ auto parentDecl = inheritanceDecl->ParentDecl;
+ RefPtr<Type> type;
+ if (auto extParentDecl = dynamic_cast<ExtensionDecl*>(parentDecl))
+ {
+ type = extParentDecl->targetType.type;
+ if (auto declRefType = type.As<DeclRefType>())
+ {
+ if (auto aggTypeDecl = declRefType->declRef.As<AggTypeDecl>())
+ parentDecl = aggTypeDecl.getDecl();
+ }
+ }
+ else
+ {
+ type = DeclRefType::Create(
+ context->getSession(),
+ makeDeclRef(parentDecl));
+ }
// What is the super-type that we have declared we inherit from?
RefPtr<Type> superType = inheritanceDecl->base.type;
// Construct the mangled name for the witness table, which depends
// on the type that is conforming, and the type that it conforms to.
- String mangledName = getMangledNameForConformanceWitness(
- makeDeclRef(parentDecl),
- superType);
+ String mangledName = getMangledNameForConformanceWitness(type, superType);
// Build an IR level witness table, which will represent the
// conformance of the type to its super-type.