Skip to content

Retain subclass fields over masked superclass fields in TypeDiscoverer#3504

Closed
mp911de wants to merge 2 commits into
mainfrom
issue/3500
Closed

Retain subclass fields over masked superclass fields in TypeDiscoverer#3504
mp911de wants to merge 2 commits into
mainfrom
issue/3500

Conversation

@mp911de

@mp911de mp911de commented Jun 23, 2026

Copy link
Copy Markdown
Member

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 mp911de added this to the 3.5.13 (2025.0.13) milestone Jun 23, 2026
@mp911de mp911de added the type: regression A regression from a previous release label Jun 23, 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
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 mp911de closed this Jun 24, 2026
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 mp911de deleted the issue/3500 branch June 24, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: regression A regression from a previous release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Property type resolved from hidden superclass field instead of subclass field

2 participants