small refactoring

This commit is contained in:
Svetlana Isakova
2012-08-03 17:52:05 +04:00
parent 036ce3c2e1
commit 792cc63197
2 changed files with 10 additions and 53 deletions
@@ -141,43 +141,6 @@ public class TabledDescriptorRenderer {
return new TableRenderer();
}
//protected final List<TableRenderer> previousTables = Lists.newArrayList();
//private TextRow currentFirstText;
//private List<TableRow> 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<TableRow> rows) {
// this.currentFirstText = firstText;
// this.currentRows = rows;
//}
//
//protected TabledDescriptorRenderer() {
// this(null, Lists.<TableRow>newArrayList());
//}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
@@ -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;