diff options
Diffstat (limited to 'source/slang/slang-check-inheritance.cpp')
| -rw-r--r-- | source/slang/slang-check-inheritance.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp index 7320d0463..3e59c5e8d 100644 --- a/source/slang/slang-check-inheritance.cpp +++ b/source/slang/slang-check-inheritance.cpp @@ -266,7 +266,7 @@ namespace Slang addDirectBaseType(baseType, satisfyingWitness); } } - else if (auto genericTypeParamDeclRef = declRef.as<GenericTypeParamDecl>()) + else if (auto genericTypeParamDeclRef = declRef.as<GenericTypeParamDeclBase>()) { // The constraints placed on a generic type parameter are siblings of that // parameter in its parent `GenericDecl`, so we need to enumerate all of @@ -298,7 +298,14 @@ namespace Slang // auto subDeclRefType = as<DeclRefType>(subType); if (!subDeclRefType) - continue; + { + if (auto subEachType = as<EachType>(subType)) + { + subDeclRefType = as<DeclRefType>(subEachType->getElementType()); + } + if (!subDeclRefType) + continue; + } if (subDeclRefType->getDeclRef() != genericTypeParamDeclRef) continue; @@ -922,6 +929,35 @@ namespace Slang info.facets = mergedFacets; return info; } + else if (auto eachType = as<EachType>(type)) + { + auto elementInheritanceInfo = getInheritanceInfo(eachType->getElementType()); + SemanticsVisitor visitor(this); + auto directFacet = new(arena) Facet::Impl( + Facet::Kind::Type, + Facet::Directness::Self, + DeclRef<Decl>(), + type, + visitor.createTypeEqualityWitness(type)); + Facet tail = directFacet; + for (auto facet : elementInheritanceInfo.facets) + { + if (facet->directness == Facet::Directness::Direct) + { + auto eachFacet = new(arena) Facet::Impl( + Facet::Kind::Type, + Facet::Directness::Direct, + facet->origin.declRef, + facet->origin.type, + astBuilder->getEachSubtypeWitness(type, facet->subtypeWitness->getSup(), facet->subtypeWitness)); + tail->next = eachFacet; + tail = eachFacet; + } + } + InheritanceInfo info; + info.facets = FacetList(directFacet); + return info; + } else { // As a fallback, any type not covered by the above cases will |
