diff options
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 85040dc55..c0d7feaff 100644 --- a/source/slang/slang-check-conversion.cpp +++ b/source/slang/slang-check-conversion.cpp @@ -1019,6 +1019,22 @@ namespace Slang *outCost = kConversionCost_CastToInterface; return true; } + else if (auto fromIsToWitness = tryGetSubtypeWitness(toType, fromType)) + { + // Is toType and fromType the same via some type equality witness? + // If so there is no need to do any conversion. + // + if (isTypeEqualityWitness(fromIsToWitness)) + { + if (outToExpr) + { + *outToExpr = createCastToSuperTypeExpr(toType, fromExpr, fromIsToWitness); + } + if (outCost) + *outCost = 0; + return true; + } + } // Disallow converting to a ParameterGroupType. // |
