diff options
| author | Theresa Foley <10618364+tangent-vector@users.noreply.github.com> | 2023-07-10 17:48:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 17:48:51 -0700 |
| commit | d9c57e613f2dacd221d9c46c10395cf373a8fcaf (patch) | |
| tree | 2aba66f2ec361cf9066c53d6eef7ee5e77f213ed /source/slang/slang-check-conversion.cpp | |
| parent | e4d7def727f75cee3f8fdfe6f286da2b8114b329 (diff) | |
Add support for texture footprint queries (#2970)
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index a6130d4e8..357b75cce 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -902,7 +902,23 @@ namespace Slang if(auto witness = tryGetSubtypeWitness(fromType, toAggTypeDeclRef)) { if (outToExpr) + { *outToExpr = createCastToSuperTypeExpr(toType, fromExpr, witness); + + // If the original expression was an l-value, then the result + // of the cast may be an l-value itself. We want to be able + // to invoke `[mutating]` methods on a value that is cast to + // an interface it conforms to, and we also expect to be able + // to pass a value of a derived `struct` type into methods that + // expect a value of its base type. + // + // TODO: vet this logic for correctness. + // + if (fromExpr && fromExpr->type.isLeftValue) + { + (*outToExpr)->type.isLeftValue = true; + } + } if (outCost) *outCost = kConversionCost_CastToInterface; return true; |
