Equals
This commit is contained in:
@@ -599,14 +599,20 @@ public class JetTypeInferrer {
|
||||
result = assignmentOperationType;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (counterpartType == null) {
|
||||
semanticServices.getErrorHandler().unresolvedReference(operationSign);
|
||||
}
|
||||
else if (equalsOperations.contains(operationType)) {
|
||||
JetType equalsType = getTypeForBinaryCall(expression, "equals", scope, true);
|
||||
if (equalsType != null) {
|
||||
// TODO : Relax?
|
||||
TypeConstructor booleanTypeConstructor = semanticServices.getStandardLibrary().getBoolean().getTypeConstructor();
|
||||
if (!equalsType.getConstructor().equals(booleanTypeConstructor)) {
|
||||
semanticServices.getErrorHandler().structuralError(operationSign.getNode(), "'equals' must return Boolean but returns " + equalsType);
|
||||
} else {
|
||||
result = counterpartType;
|
||||
result = equalsType;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
semanticServices.getErrorHandler().structuralError(operationSign.getNode(), "Unknown operation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import util.*
|
||||
~div~fun div(t : String) : Int {}
|
||||
~mod~fun mod(t : String) : Int {}
|
||||
~rangeTo~fun rangeTo(t : String) : Int {}
|
||||
~==~fun equals(a : Any?) : Boolean {}
|
||||
}
|
||||
|
||||
~t~fun <~t.T~T> t(~t.t~t : `t.T`T) : `t.T`T {
|
||||
@@ -26,6 +27,8 @@ import util.*
|
||||
x `div`/ ""
|
||||
x `mod`% ""
|
||||
x `rangeTo`.. ""
|
||||
x `==`== ""
|
||||
x `==`!= 1
|
||||
}
|
||||
|
||||
~Foo~class Foo {
|
||||
|
||||
Reference in New Issue
Block a user