private TypeReference L(final TypeReference t) { TypeReference current = t; while (current.isWildcardType()) { if (current.isUnbounded() || current.hasExtendsBound()) { return BuiltinTypes.Bottom; } current = current.getSuperBound(); } return current; }
private TypeReference L(final TypeReference t) { TypeReference current = t; while (current.isWildcardType()) { if (current.isUnbounded() || current.hasExtendsBound()) { return BuiltinTypes.Bottom; } current = current.getSuperBound(); } return current; }
private TypeReference L(final TypeReference t) { TypeReference current = t; while (current.isWildcardType()) { if (current.isUnbounded() || current.hasExtendsBound()) { return BuiltinTypes.Bottom; } current = current.getSuperBound(); } return current; }
@Override public Boolean visitGenericParameter(final GenericParameter t, final TypeReference s) { if (s instanceof GenericParameter) { // // Type substitution does not preserve type variable types; check that type variable // bounds are indeed the same. // return areSameGenericParameters(t, (GenericParameter) s); } // // Special case for s == ? super X, where upper(s) == u; check that u == t. // return s.hasSuperBound() && !s.hasExtendsBound() && visit(t, getUpperBound(s)); }
@Override public Boolean visitGenericParameter(final GenericParameter t, final TypeReference s) { if (s instanceof GenericParameter) { // // Type substitution does not preserve type variable types; check that type variable // bounds are indeed the same. // return areSameGenericParameters(t, (GenericParameter) s); } // // Special case for s == ? super X, where upper(s) == u; check that u == t. // return s.hasSuperBound() && !s.hasExtendsBound() && visit(t, getUpperBound(s)); }
@Override public Boolean visitGenericParameter(final GenericParameter t, final TypeReference s) { if (s instanceof GenericParameter) { // // Type substitution does not preserve type variable types; check that type variable // bounds are indeed the same. // return areSameGenericParameters(t, (GenericParameter) s); } // // Special case for s == ? super X, where upper(s) == u; check that u == t. // return s.hasSuperBound() && !s.hasExtendsBound() && visit(t, getUpperBound(s)); }
@Override @SuppressWarnings("StatementWithEmptyBody") public Void visitGenericParameter(final GenericParameter source, final TypeReference target) { TypeReference value = mapping.get(source); if (value != null) { if (value.hasSuperBound() && target.hasSuperBound()) { value = isSubType(getLowerBound(value), getLowerBound(target)) ? target : value; } else if (value.hasExtendsBound() && target.hasExtendsBound()) { value = isSubType(getUpperBound(value), getUpperBound(target)) ? value : target; } else if (value.isWildcardType() && value.isUnbounded()) { // do nothing } else if (!isSameType(value, target)) { throw new AdaptFailure(); } } else { value = target; from.append(source); to.append(target); } mapping.put(source, value); return null; } }
private TypeReference toRawType(TypeReference type) { if(type.hasExtendsBound()) return toRawType(type.getExtendsBound()); if(type.hasSuperBound()) return BuiltinTypes.Object; if(type instanceof GenericParameter) return toRawType(type.getUnderlyingType()); if(!type.isGenericType()) return type; try { return type.getRawType(); } catch (UnsupportedOperationException e) { return BuiltinTypes.Object; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); } return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return false; } }
@Override public TypeReference visitWildcard(final WildcardType t, final Map<TypeReference, TypeReference> map) { if (t.isUnbounded()) { return t; } final TypeReference oldBound = t.hasExtendsBound() ? t.getExtendsBound() : t.getSuperBound(); final TypeReference mapping = map.get(oldBound); if (MetadataResolver.areEquivalent(mapping, t)) { return t; } TypeReference newBound = visit(oldBound, map); while (newBound.isWildcardType()) { if (newBound.isUnbounded()) { return newBound; } newBound = newBound.hasExtendsBound() ? newBound.getExtendsBound() : newBound.getSuperBound(); } if (oldBound != newBound) { return t.hasExtendsBound() ? WildcardType.makeExtends(newBound) : WildcardType.makeSuper(newBound); } return t; }
@Override public TypeReference visitWildcard(final WildcardType t, final Map<TypeReference, TypeReference> map) { if (t.isUnbounded()) { return t; } final TypeReference oldBound = t.hasExtendsBound() ? t.getExtendsBound() : t.getSuperBound(); final TypeReference mapping = map.get(oldBound); if (MetadataResolver.areEquivalent(mapping, t)) { return t; } TypeReference newBound = visit(oldBound, map); while (newBound.isWildcardType()) { if (newBound.isUnbounded()) { return newBound; } newBound = newBound.hasExtendsBound() ? newBound.getExtendsBound() : newBound.getSuperBound(); } if (oldBound != newBound) { return t.hasExtendsBound() ? WildcardType.makeExtends(newBound) : WildcardType.makeSuper(newBound); } return t; }
@Override public TypeReference visitWildcard(final WildcardType t, final Map<TypeReference, TypeReference> map) { if (t.isUnbounded()) { return t; } final TypeReference oldBound = t.hasExtendsBound() ? t.getExtendsBound() : t.getSuperBound(); final TypeReference mapping = map.get(oldBound); if (MetadataResolver.areEquivalent(mapping, t)) { return t; } TypeReference newBound = visit(oldBound, map); while (newBound.isWildcardType()) { if (newBound.isUnbounded()) { return newBound; } newBound = newBound.hasExtendsBound() ? newBound.getExtendsBound() : newBound.getSuperBound(); } if (oldBound != newBound) { return t.hasExtendsBound() ? WildcardType.makeExtends(newBound) : WildcardType.makeSuper(newBound); } return t; }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); } return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return false; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); } return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return false; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
private static boolean isSameWildcard(final TypeReference t, final TypeReference s) { VerifyArgument.notNull(t, "t"); VerifyArgument.notNull(s, "s"); if (!t.isWildcardType() || !s.isWildcardType()) { return false; } if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasSuperBound()) { return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); }
private static boolean isSameWildcard(final TypeReference t, final TypeReference s) { VerifyArgument.notNull(t, "t"); VerifyArgument.notNull(s, "s"); if (!t.isWildcardType() || !s.isWildcardType()) { return false; } if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasSuperBound()) { return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); }
@Override public Boolean visitWildcard(final WildcardType t, final TypeReference s) { if (s.isWildcardType()) { if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasExtendsBound()) { return s.hasExtendsBound() && visit(getUpperBound(t), getUpperBound(s)); } if (t.hasSuperBound()) { return s.hasSuperBound() && visit(getLowerBound(t), getLowerBound(s)); } } return Boolean.FALSE; } }
private static boolean isSameWildcard(final TypeReference t, final TypeReference s) { VerifyArgument.notNull(t, "t"); VerifyArgument.notNull(s, "s"); if (!t.isWildcardType() || !s.isWildcardType()) { return false; } if (t.isUnbounded()) { return s.isUnbounded(); } if (t.hasSuperBound()) { return s.hasSuperBound() && isSameType(t.getSuperBound(), s.getSuperBound()); } return s.hasExtendsBound() && isSameType(t.getExtendsBound(), s.getExtendsBound()); }