diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-10 14:11:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-10 14:11:27 -0700 |
| commit | 88f04c29244af23c1cdd472d8d1ae3e5a650494e (patch) | |
| tree | 398e55440e8f7ad157d15b2b75d9887236eaa126 /source/slang/slang-check-conformance.cpp | |
| parent | fcdb4629c4c3dd2931eaa88b96b668d914c4519c (diff) | |
`is` and `as` operator and `Optional<T>`. (#2355)
* `is` and `as` operator and `Optional<T>`.
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-conformance.cpp')
| -rw-r--r-- | source/slang/slang-check-conformance.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/slang/slang-check-conformance.cpp b/source/slang/slang-check-conformance.cpp index e77ea4981..5889c6140 100644 --- a/source/slang/slang-check-conformance.cpp +++ b/source/slang/slang-check-conformance.cpp @@ -390,6 +390,28 @@ namespace Slang return _isDeclaredSubtype(subType, subType, superTypeDeclRef, nullptr, nullptr); } + bool SemanticsVisitor::isDeclaredSubtype( + Type* subType, + Type* superType) + { + if (auto declRefType = as<DeclRefType>(superType)) + { + if (auto aggTypeDeclRef = declRefType->declRef.as<AggTypeDecl>()) + return _isDeclaredSubtype(subType, subType, aggTypeDeclRef, nullptr, nullptr); + } + return false; + } + + bool SemanticsVisitor::isInterfaceType(Type* type) + { + if (auto declRefType = as<DeclRefType>(type)) + { + if (auto interfaceDeclRef = declRefType->declRef.as<InterfaceDecl>()) + return true; + } + return false; + } + Val* SemanticsVisitor::tryGetSubtypeWitness( Type* subType, DeclRef<AggTypeDecl> superTypeDeclRef) |
