This commit is contained in:
Andrey Breslav
2011-03-15 19:43:11 +03:00
parent 764fbf005e
commit 681d979a8d
2 changed files with 14 additions and 5 deletions
@@ -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 {