From 19867ffca6dca7995c799354081219c9e76f13d1 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 20 Feb 2025 14:48:51 -0800 Subject: Simplify implicit cast ctors for vector & matrix. (#6408) * Simplify implicit cast ctors for vector & matrix. * Fix formatting. * Fix tests. * Fix Falcor test. * Mark __builtin_cast as internal. --- source/slang/slang-check-decl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 1ef5b1cec..5b5e05b73 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -147,6 +147,8 @@ struct SemanticsDeclHeaderVisitor : public SemanticsDeclVisitorBase, void visitGenericTypeConstraintDecl(GenericTypeConstraintDecl* decl); + void visitTypeCoercionConstraintDecl(TypeCoercionConstraintDecl* decl); + void validateGenericConstraintSubType(GenericTypeConstraintDecl* decl, TypeExp type); void visitGenericDecl(GenericDecl* genericDecl); @@ -2911,6 +2913,16 @@ void SemanticsDeclHeaderVisitor::validateGenericConstraintSubType( } } +void SemanticsDeclHeaderVisitor::visitTypeCoercionConstraintDecl(TypeCoercionConstraintDecl* decl) +{ + CheckConstraintSubType(decl->toType); + + if (!decl->fromType.type) + decl->fromType = TranslateTypeNodeForced(decl->fromType); + if (!decl->toType.type) + decl->toType = TranslateTypeNodeForced(decl->toType); +} + void SemanticsDeclHeaderVisitor::visitGenericTypeConstraintDecl(GenericTypeConstraintDecl* decl) { // TODO: are there any other validations we can do at this point? -- cgit v1.2.3