diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-28 18:07:40 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-28 18:07:40 -0700 |
| commit | b7d318f48db2cb83a41d665f1727ae93fc555124 (patch) | |
| tree | d81d69cbba264cd059bbe67f29235226032c4793 /source/slang/slang-check-conversion.cpp | |
| parent | e7238942ea003e134b325fa65296df8e19368e90 (diff) | |
Support `constref` parameters passing. (#3249)
* Support `constref` parameters passing.
* Fix.
* Fix.
* Add test and diagnostic on mix use of __constref and no_diff.
* check for [constref] on differentiable member method.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index c4efba658..c2cfabcfe 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -991,11 +991,12 @@ namespace Slang return true; } - if (auto refType = as<RefType>(toType)) + if (auto refType = as<RefTypeBase>(toType)) { - if (!refType->getValueType()->equals(fromType)) + ConversionCost cost; + if (!canCoerce(refType->getValueType(), fromType, fromExpr, &cost)) return false; - if (!fromExpr->type.isLeftValue) + if (as<RefType>(toType) && !fromExpr->type.isLeftValue) return false; ConversionCost subCost = kConversionCost_GetRef; @@ -1016,7 +1017,7 @@ namespace Slang // Allow implicit dereferencing a reference type. - if (auto fromRefType = as<RefType>(fromType)) + if (auto fromRefType = as<RefTypeBase>(fromType)) { auto fromValueType = fromRefType->getValueType(); |
