diff options
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index c668155df..27062fc0c 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -1070,6 +1070,15 @@ namespace Slang return 0; } + int getOverloadRank(DeclRef<Decl> declRef) + { + if (!declRef.getDecl()) + return 0; + if (auto attr = declRef.getDecl()->findModifier<OverloadRankAttribute>()) + return attr->rank; + return 0; + } + int SemanticsVisitor::CompareOverloadCandidates( OverloadCandidate* left, OverloadCandidate* right) @@ -1142,6 +1151,11 @@ namespace Slang auto specificityDiff = compareOverloadCandidateSpecificity(left->item, right->item); if(specificityDiff) return specificityDiff; + + // If we reach here, we will attempt to use overload rank to break the ties. + auto overloadRankDiff = getOverloadRank(right->item.declRef) - getOverloadRank(left->item.declRef); + if (overloadRankDiff) + return overloadRankDiff; } return 0; |
