compareTo
This commit is contained in:
@@ -567,17 +567,17 @@ public class JetTypeInferrer {
|
|||||||
result = null; // TODO : This is not an expression, in fact!
|
result = null; // TODO : This is not an expression, in fact!
|
||||||
}
|
}
|
||||||
else if (comparisonOperations.contains(operationType)) {
|
else if (comparisonOperations.contains(operationType)) {
|
||||||
JetExpression left = expression.getLeft();
|
JetType compareToReturnType = getTypeForBinaryCall(expression, "compareTo", scope);
|
||||||
JetExpression deparenthesized = deparenthesize(left);
|
if (compareToReturnType != null) {
|
||||||
if (deparenthesized instanceof JetArrayAccessExpression) {
|
TypeConstructor constructor = compareToReturnType.getConstructor();
|
||||||
JetArrayAccessExpression arrayAccessExpression = (JetArrayAccessExpression) deparenthesized;
|
JetStandardLibrary standardLibrary = semanticServices.getStandardLibrary();
|
||||||
resolveArrayAccessToLValue(arrayAccessExpression, expression.getRight(), expression.getOperationReference());
|
TypeConstructor intTypeConstructor = standardLibrary.getInt().getTypeConstructor();
|
||||||
|
if (constructor.equals(intTypeConstructor)) {
|
||||||
|
result = standardLibrary.getBooleanType();
|
||||||
|
} else {
|
||||||
|
semanticServices.getErrorHandler().structuralError(operationSign.getNode(), "compareTo must return Int, but returns " + compareToReturnType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
getType(scope, expression.getRight(), false);
|
|
||||||
//throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
result = null; // TODO : This is not an expression, in fact!
|
|
||||||
} else {
|
} else {
|
||||||
semanticServices.getErrorHandler().structuralError(operationSign.getNode(), "Unknown operation");
|
semanticServices.getErrorHandler().structuralError(operationSign.getNode(), "Unknown operation");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,5 +59,8 @@ fun <T> tt(t : T) : T {
|
|||||||
`inc`++y
|
`inc`++y
|
||||||
`dec`--y
|
`dec`--y
|
||||||
y`dec`--
|
y`dec`--
|
||||||
|
1 `std::Int.compareTo(Double)`> 2.0
|
||||||
|
1 `std::Int.compareTo(Double)`< 2.0
|
||||||
|
1 `std::Int.compareTo(Double)`>= 2.0
|
||||||
|
1 `std::Int.compareTo(Double)`<= 2.0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
|||||||
nameToDescriptor.put("std::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
|
nameToDescriptor.put("std::Int.plus(Int)", standardFunction(lib.getInt(), "plus", lib.getIntType()));
|
||||||
FunctionDescriptor descriptorForGet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "get", lib.getIntType());
|
FunctionDescriptor descriptorForGet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "get", lib.getIntType());
|
||||||
nameToDescriptor.put("std::Array.get(Int)", descriptorForGet.getOriginal());
|
nameToDescriptor.put("std::Array.get(Int)", descriptorForGet.getOriginal());
|
||||||
|
nameToDescriptor.put("std::Int.compareTo(Double)", standardFunction(lib.getInt(), "compareTo", lib.getDoubleType()));
|
||||||
@NotNull
|
@NotNull
|
||||||
FunctionDescriptor descriptorForSet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "set", lib.getIntType(), lib.getIntType());
|
FunctionDescriptor descriptorForSet = standardFunction(lib.getArray(), Collections.singletonList(new TypeProjection(lib.getIntType())), "set", lib.getIntType(), lib.getIntType());
|
||||||
nameToDescriptor.put("std::Array.set(Int, Int)", descriptorForSet.getOriginal());
|
nameToDescriptor.put("std::Array.set(Int, Int)", descriptorForSet.getOriginal());
|
||||||
|
|||||||
Reference in New Issue
Block a user