diff options
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index e0dbc7e08..2ad31c9d1 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -643,12 +643,35 @@ static QualType getParamQualType(ASTBuilder* astBuilder, DeclRef<ParamDecl> para static QualType getParamQualType(Type* paramType) { + // TODO(tfoley): This function probably shouldn't exist, and instead + // the accessors for the parameters of a `FuncType` should + // directly return a `QualType` for each parameter rather than + // a plain `Type` that potentially includes a wrapping + // `ParamDirectionType`. + // + // In addition, the determination of what value category a reference + // to a parameter should be (and thus what the `QualType` sould be) + // should be driven by computing the `ParameterDirection` first, + // and then using the direction to determine the value category + // (so as to isolate the code that needs to care about the wrapper + // types to just the computation of the dirction). + // + // Note the large amount of duplication between this function and + // the other `getParamQualType()` above. + // + bool isLVal = false; + Type* valueType = paramType; if (auto paramDirType = as<ParamDirectionType>(paramType)) { - if (as<OutTypeBase>(paramDirType) || as<RefType>(paramDirType)) - return QualType(paramDirType->getValueType(), true); + valueType = paramDirType->getValueType(); + if (as<InOutParamType>(paramDirType)) + isLVal = true; + if (as<OutParamType>(paramDirType)) + isLVal = true; + if (as<RefParamType>(paramDirType)) + isLVal = true; } - return paramType; + return QualType(valueType, isLVal); } bool SemanticsVisitor::TryCheckOverloadCandidateTypes( @@ -673,7 +696,7 @@ bool SemanticsVisitor::TryCheckOverloadCandidateTypes( Count paramCount = funcType->getParamCount(); for (Index i = 0; i < paramCount; ++i) { - auto paramType = getParamQualType(funcType->getParamType(i)); + auto paramType = getParamQualType(funcType->getParamTypeWithDirectionWrapper(i)); paramTypes.add(paramType); } } @@ -2666,7 +2689,8 @@ void SemanticsVisitor::AddHigherOrderOverloadCandidates( List<QualType> paramTypes; for (Index ii = 0; ii < diffFuncType->getParamCount(); ii++) - paramTypes.add(getParamQualType(diffFuncType->getParamType(ii))); + paramTypes.add( + getParamQualType(diffFuncType->getParamTypeWithDirectionWrapper(ii))); // Try to infer generic arguments, based on the updated context. OverloadResolveContext subContext = context; |
