提交 681d979a 编写于 作者: A Andrey Breslav

Equals

上级 764fbf00
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册