summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-08-24 11:27:14 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-08-24 11:27:14 +0200
commit636e74fe397a7e93dd1955be549c901b3e9c8312 (patch)
tree2efe45fc7e9f4a18aed297a81f85434551fe9f6a
parent200ccff015e2e085a260e948eed50dfaf4cc6e8c (diff)
downloadNim-636e74fe397a7e93dd1955be549c901b3e9c8312.tar.gz
overloading resolution: scoping is considered after typing (needs to be documented)
-rw-r--r--compiler/sigmatch.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index ce4f893ea..ec429968c 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -221,13 +221,14 @@ proc cmpCandidates*(a, b: TCandidate): int =
   if result != 0: return
   result = a.convMatches - b.convMatches
   if result != 0: return
-  result = a.calleeScope - b.calleeScope
-  if result != 0: return
   # the other way round because of other semantics:
   result = b.inheritancePenalty - a.inheritancePenalty
   if result != 0: return
   # prefer more specialized generic over more general generic:
   result = complexDisambiguation(a.callee, b.callee)
+  # only as a last resort, consider scoping:
+  if result != 0: return
+  result = a.calleeScope - b.calleeScope
 
 proc writeMatches*(c: TCandidate) =
   writeLine(stdout, "exact matches: " & $c.exactMatches)