Skip to content

Commit

Permalink
Replace instance equality checks in $Gson$Types#resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
mcumings committed Sep 27, 2018
1 parent e2296f4 commit 69f7c4e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gson/src/main/java/com/google/gson/internal/$Gson$Types.java
Expand Up @@ -370,7 +370,7 @@ private static Type resolve(Type context, Class<?> contextRawType, Type toResolv
Class<?> original = (Class<?>) toResolve;
Type componentType = original.getComponentType();
Type newComponentType = resolve(context, contextRawType, componentType, visitedTypeVariables);
toResolve = componentType == newComponentType
toResolve = equal(componentType, newComponentType)
? original
: arrayOf(newComponentType);
break;
Expand All @@ -379,7 +379,7 @@ private static Type resolve(Type context, Class<?> contextRawType, Type toResolv
GenericArrayType original = (GenericArrayType) toResolve;
Type componentType = original.getGenericComponentType();
Type newComponentType = resolve(context, contextRawType, componentType, visitedTypeVariables);
toResolve = componentType == newComponentType
toResolve = equal(componentType, newComponentType)
? original
: arrayOf(newComponentType);
break;
Expand All @@ -388,12 +388,12 @@ private static Type resolve(Type context, Class<?> contextRawType, Type toResolv
ParameterizedType original = (ParameterizedType) toResolve;
Type ownerType = original.getOwnerType();
Type newOwnerType = resolve(context, contextRawType, ownerType, visitedTypeVariables);
boolean changed = newOwnerType != ownerType;
boolean changed = !equal(newOwnerType, ownerType);

Type[] args = original.getActualTypeArguments();
for (int t = 0, length = args.length; t < length; t++) {
Type resolvedTypeArgument = resolve(context, contextRawType, args[t], visitedTypeVariables);
if (resolvedTypeArgument != args[t]) {
if (!equal(resolvedTypeArgument, args[t])) {
if (!changed) {
args = args.clone();
changed = true;
Expand Down

0 comments on commit 69f7c4e

Please sign in to comment.