From 3f6838be36a9bffed779987ff335ae6753de051d Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sat, 12 Nov 2011 18:25:35 +0400 Subject: [PATCH] A quick and dirty fix for error reporting when no function is applicable --- .../jet/lang/resolve/calls/CallResolver.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 0d6ab9209ec..3973c18854d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -692,7 +692,7 @@ public class CallResolver { // TODO : maybe it's better to filter overrides out first, and only then look for the maximally specific if (successfulCandidates.size() > 0) { - OverloadResolutionResults results = chooseAndReportMaximallySpecific(successfulCandidates); + OverloadResolutionResults results = chooseAndReportMaximallySpecific(successfulCandidates, true); if (results.isAmbiguity()) { // This check is needed for the following case: // x.foo(unresolved) -- if there are multiple foo's, we'd report an ambiguity, and it does not make sense here @@ -716,7 +716,7 @@ public class CallResolver { } } if (!thisLevel.isEmpty()) { - OverloadResolutionResults results = chooseAndReportMaximallySpecific(thisLevel); + OverloadResolutionResults results = chooseAndReportMaximallySpecific(thisLevel, false); if (results.isSuccess()) { results.getResult().getTrace().commit(); return OverloadResolutionResults.singleFailedCandidate(results.getResult()); @@ -754,7 +754,7 @@ public class CallResolver { return true; } - private OverloadResolutionResults chooseAndReportMaximallySpecific(Set> candidates) { + private OverloadResolutionResults chooseAndReportMaximallySpecific(Set> candidates, boolean discriminateGenerics) { if (candidates.size() != 1) { Set> cleanCandidates = Sets.newLinkedHashSet(candidates); for (Iterator> iterator = cleanCandidates.iterator(); iterator.hasNext(); ) { @@ -772,9 +772,11 @@ public class CallResolver { return OverloadResolutionResults.success(maximallySpecific); } - ResolvedCallImpl maximallySpecificGenericsDiscriminated = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, true); - if (maximallySpecificGenericsDiscriminated != null) { - return OverloadResolutionResults.success(maximallySpecificGenericsDiscriminated); + if (discriminateGenerics) { + ResolvedCallImpl maximallySpecificGenericsDiscriminated = overloadingConflictResolver.findMaximallySpecific(cleanCandidates, true); + if (maximallySpecificGenericsDiscriminated != null) { + return OverloadResolutionResults.success(maximallySpecificGenericsDiscriminated); + } } Set> noOverrides = OverridingUtil.filterOverrides(candidates, MAP_TO_RESULT);