From 4ab3d50e4d0fd4a8b923d89cb3ce80353a929d3e Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 9 Oct 2013 17:58:48 +0400 Subject: [PATCH] rename: suggestion -> possibleAnswer --- .../calls/inference/TypeBoundsImpl.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java index a948cdb5fc0..e54129eb27d 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java @@ -144,13 +144,13 @@ public class TypeBoundsImpl implements TypeBounds { @Override public Collection getValues() { if (resultValues == null) { - resultValues = computeValues(bounds); + resultValues = computeValues(); } return resultValues; } @NotNull - private static Collection computeValues(@NotNull Collection bounds) { + private Collection computeValues() { Set values = Sets.newLinkedHashSet(); if (bounds.isEmpty()) { return Collections.emptyList(); @@ -168,7 +168,7 @@ public class TypeBoundsImpl implements TypeBounds { Set exactBounds = filterBounds(bounds, BoundKind.EXACT_BOUND, values); if (exactBounds.size() == 1) { JetType exactBound = exactBounds.iterator().next(); - if (trySuggestion(exactBound, bounds)) { + if (tryPossibleAnswer(exactBound)) { return Collections.singleton(exactBound); } } @@ -180,7 +180,7 @@ public class TypeBoundsImpl implements TypeBounds { Collection numberLowerBounds = pair.getSecond(); JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes(generalLowerBounds); - if (trySuggestion(superTypeOfLowerBounds, bounds)) { + if (tryPossibleAnswer(superTypeOfLowerBounds)) { return Collections.singleton(superTypeOfLowerBounds); } ContainerUtil.addIfNotNull(superTypeOfLowerBounds, values); @@ -188,7 +188,7 @@ public class TypeBoundsImpl implements TypeBounds { Set upperBounds = filterBounds(bounds, BoundKind.UPPER_BOUND, values); JetType intersectionOfUpperBounds = TypeUtils.intersect(JetTypeChecker.INSTANCE, upperBounds); if (!upperBounds.isEmpty() && intersectionOfUpperBounds != null) { - if (trySuggestion(intersectionOfUpperBounds, bounds)) { + if (tryPossibleAnswer(intersectionOfUpperBounds)) { return Collections.singleton(intersectionOfUpperBounds); } } @@ -199,7 +199,7 @@ public class TypeBoundsImpl implements TypeBounds { values.addAll(filterBounds(bounds, BoundKind.UPPER_BOUND)); JetType superTypeOfNumberLowerBounds = TypeUtils.commonSupertypeForNumberTypes(numberLowerBounds); - if (trySuggestion(superTypeOfNumberLowerBounds, bounds)) { + if (tryPossibleAnswer(superTypeOfNumberLowerBounds)) { return Collections.singleton(superTypeOfNumberLowerBounds); } ContainerUtil.addIfNotNull(superTypeOfNumberLowerBounds, values); @@ -207,37 +207,33 @@ public class TypeBoundsImpl implements TypeBounds { if (superTypeOfLowerBounds != null && superTypeOfNumberLowerBounds != null) { JetType superTypeOfAllLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes( Lists.newArrayList(superTypeOfLowerBounds, superTypeOfNumberLowerBounds)); - if (trySuggestion(superTypeOfAllLowerBounds, bounds)) { + if (tryPossibleAnswer(superTypeOfAllLowerBounds)) { return Collections.singleton(superTypeOfAllLowerBounds); } } return values; } - private static boolean trySuggestion( - @Nullable JetType suggestion, - @NotNull Collection bounds - ) { - if (suggestion == null) return false; - if (!suggestion.getConstructor().isDenotable()) return false; - if (filterBounds(bounds, BoundKind.EXACT_BOUND).size() > 1) return false; + private boolean tryPossibleAnswer(@Nullable JetType possibleAnswer) { + if (possibleAnswer == null) return false; + if (!possibleAnswer.getConstructor().isDenotable()) return false; for (Bound bound : bounds) { switch (bound.kind) { case LOWER_BOUND: - if (!JetTypeChecker.INSTANCE.isSubtypeOf(bound.type, suggestion)) { + if (!JetTypeChecker.INSTANCE.isSubtypeOf(bound.type, possibleAnswer)) { return false; } break; case UPPER_BOUND: - if (!JetTypeChecker.INSTANCE.isSubtypeOf(suggestion, bound.type)) { + if (!JetTypeChecker.INSTANCE.isSubtypeOf(possibleAnswer, bound.type)) { return false; } break; case EXACT_BOUND: - if (!JetTypeChecker.INSTANCE.equalTypes(bound.type, suggestion)) { + if (!JetTypeChecker.INSTANCE.equalTypes(bound.type, possibleAnswer)) { return false; } break;