mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
[PR #710] [MERGED] codegen-java: Change condition for generating equals/hashCode/toString/with/Serializable #687
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/710
Author: @odenix
Created: 10/19/2024
Status: ✅ Merged
Merged: 10/24/2024
Merged by: @bioball
Base:
main← Head:codegen-java📝 Commits (1)
f970f66codegen-java: Change condition for generating equals/hashCode/toString/with/Serializable📊 Changes
3 files changed (+958 additions, -814 deletions)
View changed files
📝
pkl-codegen-java/src/main/kotlin/org/pkl/codegen/java/JavaCodeGenerator.kt(+10 -8)📝
pkl-codegen-java/src/test/kotlin/org/pkl/codegen/java/JavaCodeGeneratorTest.kt(+936 -794)📝
pkl-codegen-java/src/test/resources/org/pkl/codegen/java/Inheritance.jva(+12 -12)📄 Description
Motivation:
equals/hashCode/toStringmethods is "generated class declares properties". As a result, classes that don't declare properties inherit these methods from their generated superclasses. However, generatedequalsandtoStringmethods aren't designed to be inherited and will either fail or produce wrong results when called for a subclass.withmethods is "class is not abstract". However, it isn't useful to generatewithmethods for non-instantiable non-abstract classes.Changes:
Change the condition for generating
equals/hashCode/toString/with/Serializableto "class is instantiable". This is a breaking change.(A generated class is instantiable, i.e., declares a public constructor, if it is neither abstract nor stateless. This behavior remains unchanged.)
Result:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.