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 you have two generic classes (e.g. Model1<T> and Model2<T>) which each have a field that references the other, the TypeAdapters for these classes will not be able to be instantiated. This is because in the constructor of a generic type adapter, all the necessary type adapters are created using new TypeAdapter. This means that Model1 instantiates Model2 in its constructor, and Model2 instantiates Model1 in its constructor, creating an infinite chain of instantiation.
Reproduction Steps
Create two generic classes that reference each other, and try to instantiate the TypeAdapters created.
Expected Behavior
The TypeAdapter should be correctly instantiated.
Actual Behavior
The TypeAdapter constructor throws a StackOverflowException
Note: Non-generic cross referential models work as expected
The text was updated successfully, but these errors were encountered:
Issue Summary
If you have two generic classes (e.g.
Model1<T>
andModel2<T>
) which each have a field that references the other, the TypeAdapters for these classes will not be able to be instantiated. This is because in the constructor of a generic type adapter, all the necessary type adapters are created usingnew TypeAdapter
. This means that Model1 instantiates Model2 in its constructor, and Model2 instantiates Model1 in its constructor, creating an infinite chain of instantiation.Reproduction Steps
Create two generic classes that reference each other, and try to instantiate the TypeAdapters created.
Expected Behavior
The TypeAdapter should be correctly instantiated.
Actual Behavior
The TypeAdapter constructor throws a StackOverflowException
Note: Non-generic cross referential models work as expected
The text was updated successfully, but these errors were encountered: