Esempio n. 1
0
  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));
  }
 /**
  * @see org.eclipse.jdt.internal.compiler.ast.Expression#tagAsUnnecessaryCast(Scope,TypeBinding)
  */
 public void tagAsUnnecessaryCast(Scope scope, TypeBinding castType) {
   // null is not instanceof Type, recognize direct scenario
   if (this.expression.resolvedType != TypeBinding.NULL)
     scope.problemReporter().unnecessaryInstanceof(this, castType);
 }