You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.
If ClassA extends ClassB and inherits fields, stag will collect all the inherited fields and use them in the creation of an object. If ClassA extends ClassB, which is in a different package than ClassA, and the members of ClassB are protected or package local (legal according to stag rules), then the type adapter for ClassA will not be able to access them.
Reproduction Steps
Take the following two classes. The generated ClassA$TypeAdapter will not be able to access field2.
A possible solution I'll put down before I forget it:
Since ClassB has a valid type adapter that can access the forbidden fields, it's possible that we could change the way the ClassA type adapter is generated. Instead of each type adapter re-adding all the field assignments, a type adapter could use the type adapter from the inherited type in order to fill its fields.
This seems potentially very complicated, so maybe it would be better to just enforce public fields if a descendent class type adapter can't access parent fields.
Related to this bug, if a class has a static member class that is non-public, or itself is non-public, Stag will fail to compile as it cannot access the inner class from the generated Stag.class.
Issue Summary
If
ClassA
extendsClassB
and inherits fields, stag will collect all the inherited fields and use them in the creation of an object. IfClassA
extendsClassB
, which is in a different package thanClassA
, and the members ofClassB
are protected or package local (legal according to stag rules), then the type adapter forClassA
will not be able to access them.Reproduction Steps
Take the following two classes. The generated
ClassA$TypeAdapter
will not be able to accessfield2
.Expected Behavior
Stag should either be able to access the fields, or should enforce a rule requiring classes that are extended to make their members public.
Actual Behavior
Given the example above, the generated
ClassA$TypeAdapter
will not be able to accessfield2
.The text was updated successfully, but these errors were encountered: