From 792cc63197375b472a845adb6f676d6074caf8c6 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 3 Aug 2012 17:52:05 +0400 Subject: [PATCH] small refactoring --- .../rendering/TabledDescriptorRenderer.java | 37 ------------------- .../calls/inference/ConstraintsUtil.java | 26 +++++-------- 2 files changed, 10 insertions(+), 53 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/TabledDescriptorRenderer.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/TabledDescriptorRenderer.java index 65f82c9d199..44a0c395d78 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/TabledDescriptorRenderer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/TabledDescriptorRenderer.java @@ -141,43 +141,6 @@ public class TabledDescriptorRenderer { return new TableRenderer(); } - - //protected final List previousTables = Lists.newArrayList(); - //private TextRow currentFirstText; - //private List currentRows; - // - //public TabledDescriptorRenderer newElement() { - // previousTables.add(new TableRenderer(currentFirstText, currentRows)); - // currentFirstText = null; - // currentRows = Lists.newArrayList(); - // return this; - //} - // - //public TabledDescriptorRenderer text(String text) { - // if (currentRows.isEmpty()) { - // currentFirstText = new TextRow(text); - // return this; - // } - // currentRows.add(new TextRow(text)); - // return this; - //} - // - //public TabledDescriptorRenderer text(String text, Object... args) { - // return text(String.format(text, args)); - //} - - - - - //private TabledDescriptorRenderer(@Nullable TextRow firstText, @NotNull List rows) { - // this.currentFirstText = firstText; - // this.currentRows = rows; - //} - // - //protected TabledDescriptorRenderer() { - // this(null, Lists.newArrayList()); - //} - @Override public String toString() { StringBuilder result = new StringBuilder(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java index 3422aeda22e..3198f66a261 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintsUtil.java @@ -39,28 +39,28 @@ public class ConstraintsUtil { values.addAll(typeConstraints.getExactBounds()); if (!typeConstraints.getLowerBounds().isEmpty()) { JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertype(typeConstraints.getLowerBounds()); - if (values.isEmpty()) { - values.add(superTypeOfLowerBounds); - } for (JetType value : values) { if (!JetTypeChecker.INSTANCE.isSubtypeOf(superTypeOfLowerBounds, value)) { values.add(superTypeOfLowerBounds); break; } } + if (values.isEmpty()) { + values.add(superTypeOfLowerBounds); + } } if (!typeConstraints.getUpperBounds().isEmpty()) { //todo subTypeOfUpperBounds JetType subTypeOfUpperBounds = typeConstraints.getUpperBounds().iterator().next(); //todo - if (values.isEmpty()) { - values.add(subTypeOfUpperBounds); - } for (JetType value : values) { if (!JetTypeChecker.INSTANCE.isSubtypeOf(value, subTypeOfUpperBounds)) { values.add(subTypeOfUpperBounds); break; } } + if (values.isEmpty()) { + values.add(subTypeOfUpperBounds); + } } } return values; @@ -141,10 +141,10 @@ public class ConstraintsUtil { assert typeConstraints != null; JetType type = getValue(typeConstraints); JetType upperBound = typeParameter.getUpperBoundsAsType(); - JetType substitute = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT); + JetType substitutedType = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT); if (type != null) { - if (substitute == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitute)) { + if (substitutedType == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitutedType)) { return false; } } @@ -153,14 +153,8 @@ public class ConstraintsUtil { public static boolean checkBoundsAreSatisfied(@NotNull ConstraintSystem constraintSystem) { for (TypeParameterDescriptor typeVariable : constraintSystem.getTypeVariables()) { - JetType type = getValue(constraintSystem.getTypeConstraints(typeVariable)); - JetType upperBound = typeVariable.getUpperBoundsAsType(); - JetType substitutedType = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT); - - if (type != null) { - if (substitutedType == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitutedType)) { - return false; - } + if (!checkUpperBoundIsSatisfied(constraintSystem, typeVariable)) { + return false; } } return true;