From 88f04c29244af23c1cdd472d8d1ae3e5a650494e Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 Aug 2022 14:11:27 -0700 Subject: `is` and `as` operator and `Optional`. (#2355) * `is` and `as` operator and `Optional`. * Fix. Co-authored-by: Yong He --- source/slang/slang-check-conformance.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/slang/slang-check-conformance.cpp') 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(superType)) + { + if (auto aggTypeDeclRef = declRefType->declRef.as()) + return _isDeclaredSubtype(subType, subType, aggTypeDeclRef, nullptr, nullptr); + } + return false; + } + + bool SemanticsVisitor::isInterfaceType(Type* type) + { + if (auto declRefType = as(type)) + { + if (auto interfaceDeclRef = declRefType->declRef.as()) + return true; + } + return false; + } + Val* SemanticsVisitor::tryGetSubtypeWitness( Type* subType, DeclRef superTypeDeclRef) -- cgit v1.2.3