diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-26 17:35:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-26 17:35:24 -0700 |
| commit | dfdf243f07c977fa59b1a5968ce053bf590f8120 (patch) | |
| tree | 6121218f9e4d664722ed6192ca08f7c0e3c1d45b /source/slang/slang-check-conversion.cpp | |
| parent | 0877d1a3e9d69fdbf4087581df96954e56e4dd97 (diff) | |
Support mutable existential parameters. (#3836)
* Support mutable existential parameters.
* Update test.
Diffstat (limited to 'source/slang/slang-check-conversion.cpp')
| -rw-r--r-- | source/slang/slang-check-conversion.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/slang/slang-check-conversion.cpp b/source/slang/slang-check-conversion.cpp index a2381c7f7..aeb964cc9 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -932,11 +932,15 @@ namespace Slang // 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 the original type is a concrete type and toType is an interface type, + // we need to wrap the original expression into a MakeExistential, and the + // result of MakeExistential is not an l-value. + bool toTypeIsInterface = isInterfaceType(toType); + bool fromTypeIsInterface = isInterfaceType(fromType); + if (!toTypeIsInterface || toTypeIsInterface == fromTypeIsInterface) + (*outToExpr)->type.isLeftValue = true; } } if (outCost) |
