Skip to content

Conversation

@ianbotsf
Copy link
Contributor

Issue #

(none)

Description of changes

StructureGenerator's equality methods don't check for nullability of member symbols, leading to unnecessary null checks.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ianbotsf ianbotsf requested a review from a team as a code owner July 30, 2025 00:19
@ianbotsf ianbotsf added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Jul 30, 2025
@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link

Affected Artifacts

No artifacts changed size

.write("if (!#1L.contentEquals(other.#1L)) return false", memberName)
.closeBlock("} else if (other.#1L != null) return false", memberName)
} else {
write("if (!#1L.contentEquals(other.#1L)) return false", memberName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking the nullability of other.#1L? It's done in the block above

.write("if (other.#1L == null) return false", memberName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we're checking equality between two instances of the same shape. If this.foo cannot be null then other.foo cannot be null either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it!

.write("if (!#1L[i].contentEquals(other.#1L[i])) return false", memberName)
.closeBlock("}")
.closeBlock("} else if (other.#1L != null) return false", memberName)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

.write("if (!#1L.contentEquals(other.#1L)) return false", memberName)
.closeBlock("} else if (other.#1L != null) return false", memberName)
} else {
write("if (!#1L.contentEquals(other.#1L)) return false", memberName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it!

@ianbotsf ianbotsf merged commit 57fdb54 into main Jul 30, 2025
21 of 22 checks passed
@ianbotsf ianbotsf deleted the fix-structure-equality-nullability branch July 30, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants