summaryrefslogtreecommitdiff
path: root/source/slang/lower-to-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-15 13:54:57 -0800
committerGitHub <noreply@github.com>2018-01-15 13:54:57 -0800
commit8abae0515d734c51e7d55c44ccfdadefea8c6802 (patch)
treebf959f2c7e41223c30d1883d26528d40f7f17916 /source/slang/lower-to-ir.cpp
parente86ab5fff089b90cb037a97d525e819faca1fa73 (diff)
parentcff418ba55e60a45554a8fb77dea756b8724396f (diff)
Merge pull request #365 from csyonghe/extension
Allow extension of a concrete type to implement additional interface
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.