Skip to content

Commit

Permalink
SLING-9706 - The HTL Java Compiler does not correctly negate equals
Browse files Browse the repository at this point in the history
  • Loading branch information
raducotescu committed Aug 27, 2020
1 parent 00e83a1 commit c092fb4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void generate(JavaSource source, ExpressionTranslator visitor, TypedNode
Type type = OpHelper.sameType(left, right);
if (type != null && OpHelper.isNumericType(type) || type == Type.BOOLEAN || type == Type.UNKNOWN) {
generateEqualsOperator(source, visitor, left.getNode(), right.getNode());
} else if (type != Type.UNKNOWN) {
} else {
generateEqualsMethod(source, visitor, left, right);
}
}
Expand All @@ -62,6 +62,9 @@ private void generateCheckedEquals(JavaSource source, SideEffectVisitor visitor,

private void generateEqualsMethod(JavaSource source, SideEffectVisitor visitor, TypedNode leftNode, TypedNode rightNode) {
boolean performCast = leftNode.getType().isPrimitive();
if (negated) {
source.negation();
}
if (performCast) {
source.startExpression();
source.cast(Type.UNKNOWN.getNativeClass());
Expand Down

0 comments on commit c092fb4

Please sign in to comment.