small refactoring
This commit is contained in:
-37
@@ -141,43 +141,6 @@ public class TabledDescriptorRenderer {
|
|||||||
return new TableRenderer();
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|||||||
+10
-16
@@ -39,28 +39,28 @@ public class ConstraintsUtil {
|
|||||||
values.addAll(typeConstraints.getExactBounds());
|
values.addAll(typeConstraints.getExactBounds());
|
||||||
if (!typeConstraints.getLowerBounds().isEmpty()) {
|
if (!typeConstraints.getLowerBounds().isEmpty()) {
|
||||||
JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertype(typeConstraints.getLowerBounds());
|
JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertype(typeConstraints.getLowerBounds());
|
||||||
if (values.isEmpty()) {
|
|
||||||
values.add(superTypeOfLowerBounds);
|
|
||||||
}
|
|
||||||
for (JetType value : values) {
|
for (JetType value : values) {
|
||||||
if (!JetTypeChecker.INSTANCE.isSubtypeOf(superTypeOfLowerBounds, value)) {
|
if (!JetTypeChecker.INSTANCE.isSubtypeOf(superTypeOfLowerBounds, value)) {
|
||||||
values.add(superTypeOfLowerBounds);
|
values.add(superTypeOfLowerBounds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
values.add(superTypeOfLowerBounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!typeConstraints.getUpperBounds().isEmpty()) {
|
if (!typeConstraints.getUpperBounds().isEmpty()) {
|
||||||
//todo subTypeOfUpperBounds
|
//todo subTypeOfUpperBounds
|
||||||
JetType subTypeOfUpperBounds = typeConstraints.getUpperBounds().iterator().next(); //todo
|
JetType subTypeOfUpperBounds = typeConstraints.getUpperBounds().iterator().next(); //todo
|
||||||
if (values.isEmpty()) {
|
|
||||||
values.add(subTypeOfUpperBounds);
|
|
||||||
}
|
|
||||||
for (JetType value : values) {
|
for (JetType value : values) {
|
||||||
if (!JetTypeChecker.INSTANCE.isSubtypeOf(value, subTypeOfUpperBounds)) {
|
if (!JetTypeChecker.INSTANCE.isSubtypeOf(value, subTypeOfUpperBounds)) {
|
||||||
values.add(subTypeOfUpperBounds);
|
values.add(subTypeOfUpperBounds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
values.add(subTypeOfUpperBounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
@@ -141,10 +141,10 @@ public class ConstraintsUtil {
|
|||||||
assert typeConstraints != null;
|
assert typeConstraints != null;
|
||||||
JetType type = getValue(typeConstraints);
|
JetType type = getValue(typeConstraints);
|
||||||
JetType upperBound = typeParameter.getUpperBoundsAsType();
|
JetType upperBound = typeParameter.getUpperBoundsAsType();
|
||||||
JetType substitute = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT);
|
JetType substitutedType = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT);
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
if (substitute == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitute)) {
|
if (substitutedType == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitutedType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,14 +153,8 @@ public class ConstraintsUtil {
|
|||||||
|
|
||||||
public static boolean checkBoundsAreSatisfied(@NotNull ConstraintSystem constraintSystem) {
|
public static boolean checkBoundsAreSatisfied(@NotNull ConstraintSystem constraintSystem) {
|
||||||
for (TypeParameterDescriptor typeVariable : constraintSystem.getTypeVariables()) {
|
for (TypeParameterDescriptor typeVariable : constraintSystem.getTypeVariables()) {
|
||||||
JetType type = getValue(constraintSystem.getTypeConstraints(typeVariable));
|
if (!checkUpperBoundIsSatisfied(constraintSystem, typeVariable)) {
|
||||||
JetType upperBound = typeVariable.getUpperBoundsAsType();
|
return false;
|
||||||
JetType substitutedType = constraintSystem.getResultingSubstitutor().substitute(upperBound, Variance.INVARIANT);
|
|
||||||
|
|
||||||
if (type != null) {
|
|
||||||
if (substitutedType == null || !JetTypeChecker.INSTANCE.isSubtypeOf(type, substitutedType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user