Retain subclass fields over masked superclass fields in TypeDiscoverer#3504
Closed
mp911de wants to merge 2 commits into
Closed
Retain subclass fields over masked superclass fields in TypeDiscoverer#3504mp911de wants to merge 2 commits into
TypeDiscoverer#3504mp911de wants to merge 2 commits into
Conversation
…er`. When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field. This happened because ReflectionUtils.doWithFields traverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map. As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type. We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration. Closes #3500
mp911de
added a commit
that referenced
this pull request
Jun 24, 2026
…er`. When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field. This happened because ReflectionUtils.doWithFields traverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map. As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type. We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration. Closes #3500 Original pull request: #3504
mp911de
added a commit
that referenced
this pull request
Jun 24, 2026
…er`. When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field. This happened because ReflectionUtils.doWithFields traverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map. As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type. We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration. Closes #3500 Original pull request: #3504
mp911de
added a commit
that referenced
this pull request
Jun 24, 2026
…er`. When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field. This happened because ReflectionUtils.doWithFields traverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map. As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type. We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration. Closes #3500 Original pull request: #3504
mp911de
added a commit
that referenced
this pull request
Jun 24, 2026
…er`. When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field. This happened because ReflectionUtils.doWithFields traverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map. As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type. We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration. Closes #3500 Original pull request: #3504
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a class hides a superclass field by declaring a field of the same name, property discovery overwrote the property type from the superclass field instead of retaining the declaring subclass field.
This happened because
ReflectionUtils.doWithFieldstraverses fields from the leaf type up through its superclasses, and the field callback unconditionally put each field into the result map.As a result, the superclass field, visited last, overwrote the entry contributed by the subclass, exposing the wrong (and potentially incompatible) property type.
We now keep the first field encountered for a given name, which is the one declared closest to the inspected type, so a hidden superclass field no longer overrides the subclass declaration.
Closes #3500