diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java index 0a5ca948adc..f07953f6d81 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/ResolutionTaskHolder.java @@ -58,17 +58,23 @@ public class ResolutionTaskHolder { } public void addCandidates(@NotNull Collection> candidates) { + assertNotFinished(); if (!candidates.isEmpty()) { candidatesList.add(setIsSafeCall(candidates)); } } public void addCandidates(@NotNull List>> candidatesList) { + assertNotFinished(); for (Collection> candidates : candidatesList) { addCandidates(candidates); } } + private void assertNotFinished() { + assert tasks == null : "Can't add candidates after the resulting tasks were computed."; + } + public List> getTasks() { if (tasks == null) { tasks = Lists.newArrayList(); @@ -76,12 +82,14 @@ public class ResolutionTaskHolder { for (int priority = priorityProvider.getMaxPriority(); priority >= 0; priority--) { final int finalPriority = priority; for (Collection> candidates : candidatesList) { - Collection> filteredCandidates = Collections2.filter(candidates, new Predicate>() { - @Override - public boolean apply(@Nullable ResolutionCandidate input) { - return finalPriority == priorityProvider.getPriority(input); - } - }); + Collection> filteredCandidates = Collections2.filter( + candidates, new Predicate>() { + @Override + public boolean apply(@Nullable ResolutionCandidate input) { + return finalPriority == priorityProvider.getPriority(input); + } + } + ); if (!filteredCandidates.isEmpty()) { tasks.add(new ResolutionTask(filteredCandidates, basicCallResolutionContext, tracing)); }