diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-06-25 12:01:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-25 10:01:54 -0700 |
| commit | d48f050cb0209a4ba9819a094ffd1e7a7c2524ee (patch) | |
| tree | a2ab97ad7c5df7d05f0a91f6c272bf25396754c0 /source/slang | |
| parent | 7e8c85e85440c1fea42236a8ef8286e1ce1638ce (diff) | |
Fix ambiguous reference for 'extern' and 'export' (#7515)
Close #7509.
When there are both `export` and `extern` decls in lookup result,
we should remove all `extern` decls.
Diffstat (limited to 'source/slang')
| -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 8d76d2554..7a89f2e23 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -1328,6 +1328,20 @@ int SemanticsVisitor::CompareLookupResultItems( bool rightIsExtension = false; bool leftIsFreeFormExtension = false; bool rightIsFreeFormExtension = false; + bool leftIsExtern = left.declRef.getDecl()->hasModifier<ExternModifier>(); + bool rigthIsExtern = right.declRef.getDecl()->hasModifier<ExternModifier>(); + + // If both left and right are extern, then they are equal. + // If only one of them is extern, then the other one is preferred. + // If neither is extern, then we continue with the rest of the checks. + if (leftIsExtern) + { + return (rigthIsExtern ? 0 : 1); + } + if (rigthIsExtern) + { + return (leftIsExtern ? -1 : 0); + } // Prefer declarations that are not in free-form generic extensions, i.e. // `extension<T:IFoo> T { /* declaration here should have lower precedence. */ } |
