From dc783a916ccba733bd781c5108bcfdf0c052c24e Mon Sep 17 00:00:00 2001 From: James Duong Date: Wed, 18 Sep 2024 16:19:33 -0700 Subject: [PATCH] Merge fixes --- .../linq4j/tree/MethodDeclaration.java | 37 +++++++++++++------ .../calcite/linq4j/test/ExpressionTest.java | 4 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java index c20fbff2850..6634a6cd968 100644 --- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java +++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java @@ -26,8 +26,6 @@ import java.util.List; import java.util.Objects; -import static java.util.Objects.requireNonNull; - /** * Declaration of a method. */ @@ -40,11 +38,15 @@ public class MethodDeclaration extends MemberDeclaration { public MethodDeclaration(int modifier, String name, Type resultType, List parameters, BlockStatement body) { + assert name != null : "name should not be null"; + assert resultType != null : "resultType should not be null"; + assert parameters != null : "parameters should not be null"; + assert body != null : "body should not be null"; this.modifier = modifier; - this.name = requireNonNull(name, "name"); - this.resultType = requireNonNull(resultType, "resultType"); - this.parameters = requireNonNull(parameters, "parameters"); - this.body = requireNonNull(body, "body"); + this.name = name; + this.resultType = resultType; + this.parameters = parameters; + this.body = body; } @Override public MemberDeclaration accept(Shuttle shuttle) { @@ -103,11 +105,24 @@ public MethodDeclaration(int modifier, String name, Type resultType, } MethodDeclaration that = (MethodDeclaration) o; - return modifier == that.modifier - && body.equals(that.body) - && name.equals(that.name) - && parameters.equals(that.parameters) - && resultType.equals(that.resultType); + + if (modifier != that.modifier) { + return false; + } + if (!body.equals(that.body)) { + return false; + } + if (!name.equals(that.name)) { + return false; + } + if (!parameters.equals(that.parameters)) { + return false; + } + if (!resultType.equals(that.resultType)) { + return false; + } + + return true; } @Override public int hashCode() { diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java index 0ad71669bb3..eb1acd39e59 100644 --- a/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java +++ b/linq4j/src/test/java/org/apache/calcite/linq4j/test/ExpressionTest.java @@ -1612,7 +1612,7 @@ public void checkBlockBuilder(boolean optimizing, String expected) { @Test void testEmptyMapLiteral() { assertEquals("com.google.common.collect.ImmutableMap.of()", - Expressions.toString(Expressions.constant(new HashMap<>()))); + Expressions.toString(Expressions.constant(new HashMap<>()), false)); } @Test void testOneElementMapLiteral() { @@ -1652,7 +1652,7 @@ public void checkBlockBuilder(boolean optimizing, String expected) { @Test void testEmptySetLiteral() { assertEquals("com.google.common.collect.ImmutableSet.of()", - Expressions.toString(Expressions.constant(new HashSet<>()))); + Expressions.toString(Expressions.constant(new HashSet<>()), false)); } @Test void testOneElementSetLiteral() {