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
The internal class TypeAdapterRuntimeTypeWrapper is supposed to prefer custom adapters for the compile type over the reflective adapter for the runtime type. However, when the compile type and the runtime type only have a reflective adapter, then it should prefer the runtime type adapter.
The problem is that this logic is not working for classes with cyclic dependencies which therefore have a Gson$FutureTypeAdapter wrapping a reflective adapter because the following line does not consider this:
Baseb = newBase();
b.f = newSub(2);
Stringjson = newGson().toJson(b);
// Fails because reflective adapter for base class is used, therefore json is: {"f":{}}assertEquals("{\"f\":{\"i\":2}}", json);
Note: This is similar to the problem #1787 tries to fix for TreeTypeAdapter.