private static Type erasure(final Type t, final boolean recurse) { if (t.isPrimitive()) { return t; // fast special case } else { return ErasureVisitor.visit(t, recurse); } }
public static boolean covariantReturnType(final Type t, final Type s) { return isSameType(t, s) || !t.isPrimitive() && !s.isPrimitive() && isAssignable(t, s); }
public Type visitType(final Type t, final Boolean recurse) { if (t.isPrimitive()) { return t; // fast special case } else { return (recurse ? ErasureRecursiveFunctor : ErasureFunctor).apply(t); } }
public static boolean areReferenceAssignable(final Type<?> destination, final Type<?> source) { if (destination == Types.Object) { return true; } // WARNING: This actually checks "is this identity assignable and/or reference assignable?" return hasIdentityPrimitiveOrBoxingConversion(source, destination) || !destination.isPrimitive() && !source.isPrimitive() && destination.isAssignableFrom(source); }
public Type visitType(final Type t, final Boolean recurse) { if (t.isPrimitive()) { return t; // fast special case } else { return (recurse ? ErasureRecursiveFunctor : ErasureFunctor).apply(t); } }
public static boolean areReferenceAssignable(final Type<?> destination, final Type<?> source) { if (destination == Types.Object) { return true; } // WARNING: This actually checks "is this identity assignable and/or reference assignable?" return hasIdentityPrimitiveOrBoxingConversion(source, destination) || !destination.isPrimitive() && !source.isPrimitive() && destination.isAssignableFrom(source); }
public Type visitType(final Type t, final Boolean recurse) { if (t.isPrimitive()) { return t; // fast special case } else { return (recurse ? ErasureRecursiveFunctor : ErasureFunctor).apply(t); } }
private void emitBoxedToUnboxedConversion(final Type<?> sourceType, final Type<?> targetType) { assert TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive() : "TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive()"; if (targetType.isPrimitive()) { emitBoxedToUnboxedNumericConversion(sourceType, targetType); } else { emitBoxedToReferenceConversion(sourceType); } }
private void emitBoxedToUnboxedConversion(final Type<?> sourceType, final Type<?> targetType) { assert TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive() : "TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive()"; if (targetType.isPrimitive()) { emitBoxedToUnboxedNumericConversion(sourceType, targetType); } else { emitBoxedToReferenceConversion(sourceType); } }
private void emitBoxedToUnboxedConversion(final Type<?> sourceType, final Type<?> targetType) { assert TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive() : "TypeUtils.isAutoUnboxed(sourceType) && targetType.isPrimitive()"; if (targetType.isPrimitive()) { emitBoxedToUnboxedNumericConversion(sourceType, targetType); } else { emitBoxedToReferenceConversion(sourceType); } }
public static boolean hasReferenceEquality(final Type<?> left, final Type<?> right) { if (left.isPrimitive() || right.isPrimitive()) { return false; } // If we have an interface and a reference type then we can do // reference equality. // If we have two reference types and one is assignable to the // other then we can do reference equality. return left.isInterface() || right.isInterface() || areReferenceAssignable(left, right) || areReferenceAssignable(right, left); }
public static boolean hasReferenceEquality(final Type<?> left, final Type<?> right) { if (left.isPrimitive() || right.isPrimitive()) { return false; } // If we have an interface and a reference type then we can do // reference equality. // If we have two reference types and one is assignable to the // other then we can do reference equality. return left.isInterface() || right.isInterface() || areReferenceAssignable(left, right) || areReferenceAssignable(right, left); }
@Override public Type visitArrayType(final Type t, final Void ignored) { final Type elementType = t.getElementType(); if (elementType.isPrimitive() || isSameType(elementType, Types.Object)) { return arraySuperType(); } else { return new ArrayType(superType(elementType)); } } };
@Override public Type visitArrayType(final Type t, final Void ignored) { final Type elementType = t.getElementType(); if (elementType.isPrimitive() || isSameType(elementType, Types.Object)) { return arraySuperType(); } else { return new ArrayType(superType(elementType)); } } };
public void emitNew(final Type<?> type) { VerifyArgument.notNull(type, "type"); if (type.containsGenericParameters()) { throw Error.cannotInstantiateUnboundGenericType(type); } if (type.isPrimitive()) { emitDefaultValue(type); return; } emit(OpCode.NEW, type); }
private void emitUnboxedToBoxedConversion(final Type<?> sourceType, final Type<?> targetType) { assert sourceType.isPrimitive() && TypeUtils.isAutoUnboxed(targetType) : "sourceType.isPrimitive() && TypeUtils.isAutoUnboxed(targetType)"; final Type<?> unboxedTargetType = TypeUtils.getUnderlyingPrimitive(targetType); final LocalBuilder targetLocal = declareLocal(targetType); emitConversion(sourceType, unboxedTargetType); emitBox(targetType); }
@Override public Boolean visitArrayType(final Type t, final Type s) { final Type elementType = t.getElementType(); if (elementType.isPrimitive()) { return isSameType(elementType, elementType(s)); } return isSubtypeNoCapture(elementType, elementType(s)); } };
@Override public Boolean visitArrayType(final Type t, final Type s) { final Type elementType = t.getElementType(); if (elementType.isPrimitive()) { return isSameType(elementType, elementType(s)); } return isSubtypeNoCapture(elementType, elementType(s)); } };
@Override public Boolean visitArrayType(final Type t, final Type s) { final Type elementType = t.getElementType(); if (elementType.isPrimitive()) { return isSameType(elementType, elementType(s)); } return isSubtypeNoCapture(elementType, elementType(s)); } };
private void emitUnboxedToBoxedConversion(final Type<?> sourceType, final Type<?> targetType) { assert sourceType.isPrimitive() && TypeUtils.isAutoUnboxed(targetType) : "sourceType.isPrimitive() && TypeUtils.isAutoUnboxed(targetType)"; final Type<?> unboxedTargetType = TypeUtils.getUnderlyingPrimitive(targetType); final LocalBuilder targetLocal = declareLocal(targetType); emitConversion(sourceType, unboxedTargetType); emitBox(targetType); }