/* (non-Javadoc) * @see ITypeBinding#isAssignmentCompatible(ITypeBinding) */ public boolean isAssignmentCompatible(ITypeBinding type) { try { if (this == type) return true; if (!(type instanceof TypeBinding)) return false; TypeBinding other = (TypeBinding) type; Scope scope = this.resolver.scope(); if (scope == null) return false; return this.binding.isCompatibleWith(other.binding) || scope.isBoxingCompatibleWith(this.binding, other.binding); } catch (AbortCompilation e) { // don't surface internal exception to clients // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=143013 return false; } }
protected boolean isBoxingCompatible( TypeBinding expressionType, TypeBinding targetType, Expression expression, Scope scope) { if (scope.isBoxingCompatibleWith(expressionType, targetType)) return true; return expressionType .isBaseType() // narrowing then boxing ? Only allowed for some target types see 362279 && !targetType.isBaseType() && !targetType.isTypeVariable() && scope.compilerOptions().sourceLevel >= org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants.JDK1_5 // autoboxing && (targetType.id == TypeIds.T_JavaLangByte || targetType.id == TypeIds.T_JavaLangShort || targetType.id == TypeIds.T_JavaLangCharacter) && expression.isConstantValueOfTypeAssignableToType( expressionType, scope.environment().computeBoxingType(targetType)); }