Пример #1
0
 /**
  * @see
  *     org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope,
  *     org.eclipse.jdt.internal.compiler.lookup.TypeBinding,
  *     org.eclipse.jdt.internal.compiler.lookup.TypeBinding)
  */
 public void computeConversion(
     Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
   if (runtimeTimeType == null || compileTimeType == null) return;
   // set the generic cast after the fact, once the type expectation is fully known (no need for
   // strict cast)
   if (this.binding != null && this.binding.isValidBinding()) {
     MethodBinding originalBinding = this.binding.original();
     TypeBinding originalType = originalBinding.returnType;
     // extra cast needed if method return type is type variable
     if (originalType.leafComponentType().isTypeVariable()) {
       TypeBinding targetType =
           (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType())
               ? compileTimeType // unboxing: checkcast before conversion
               : runtimeTimeType;
       this.valueCast = originalType.genericCast(targetType);
     } else if (this.binding == scope.environment().arrayClone
         && runtimeTimeType.id != TypeIds.T_JavaLangObject
         && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
       // from 1.5 source level on, array#clone() resolves to array type, but codegen to
       // #clone()Object - thus require extra inserted cast
       this.valueCast = runtimeTimeType;
     }
     if (this.valueCast instanceof ReferenceBinding) {
       ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast;
       if (!referenceCast.canBeSeenBy(scope)) {
         scope
             .problemReporter()
             .invalidType(
                 this,
                 new ProblemReferenceBinding(
                     CharOperation.splitOn('.', referenceCast.shortReadableName()),
                     referenceCast,
                     ProblemReasons.NotVisible));
       }
     }
   }
   super.computeConversion(scope, runtimeTimeType, compileTimeType);
 }