Fix CompareTo intrinsic behavior in no-dot syntax

This commit is contained in:
Alexander Udalov
2013-01-22 19:28:06 +04:00
parent 44dcdde513
commit ab730b7dd5
5 changed files with 43 additions and 1 deletions
@@ -41,8 +41,18 @@ public class CompareTo implements IntrinsicMethod {
StackValue receiver,
@NotNull GenerationState state
) {
JetExpression argument;
assert arguments != null;
JetExpression argument = arguments.get(0);
if (arguments.size() == 1) {
argument = arguments.get(0);
}
else if (arguments.size() == 2) {
receiver = codegen.gen(arguments.get(0));
argument = arguments.get(1);
}
else {
throw new IllegalStateException("Invalid arguments to compareTo: " + arguments);
}
Type type = comparisonOperandType(receiver.type, codegen.expressionType(argument));
receiver.put(type, v);