/**
  * @see
  *     org.eclipse.che.ide.ext.java.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup.Scope,
  *     org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup.TypeBinding,
  *     org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup .TypeBinding)
  */
 public void computeConversion(
     Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
   if (runtimeTimeType == null || compileTimeType == null) return;
   if ((this.bits & Binding.FIELD) != 0 && this.binding != null && this.binding.isValidBinding()) {
     // set the generic cast after the fact, once the type expectation is fully known (no need for
     // strict cast)
     FieldBinding field = (FieldBinding) this.binding;
     FieldBinding originalBinding = field.original();
     TypeBinding originalType = originalBinding.type;
     // extra cast needed if field type is type variable
     if (originalType.leafComponentType().isTypeVariable()) {
       TypeBinding targetType =
           (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType())
               ? compileTimeType
               // unboxing: checkcast before conversion
               : runtimeTimeType;
       this.genericCast = originalType.genericCast(scope.boxing(targetType));
       if (this.genericCast instanceof ReferenceBinding) {
         ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast;
         if (!referenceCast.canBeSeenBy(scope)) {
           scope
               .problemReporter()
               .invalidType(
                   this,
                   new ProblemReferenceBinding(
                       CharOperation.splitOn('.', referenceCast.shortReadableName()),
                       referenceCast,
                       ProblemReasons.NotVisible));
         }
       }
     }
   }
   super.computeConversion(scope, runtimeTimeType, compileTimeType);
 }
Example #2
0
 /*
  * @see IBinding#isEqualTo(Binding)
  * @since 3.1
  */
 public boolean isEqualTo(IBinding other) {
   if (other == this) {
     // identical binding - equal (key or no key)
     return true;
   }
   if (other == null) {
     // other binding missing
     return false;
   }
   if (!(other instanceof PackageBinding)) {
     return false;
   }
   org.eclipse.che.ide.ext.java.jdt.internal.compiler.lookup.PackageBinding packageBinding2 =
       ((PackageBinding) other).binding;
   return CharOperation.equals(this.binding.compoundName, packageBinding2.compoundName);
 }
Example #3
0
  public void bind(MethodScope scope, TypeBinding typeBinding, boolean used) {

    // record the resolved type into the type reference
    Binding existingVariable =
        scope.getBinding(this.name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
    if (existingVariable != null && existingVariable.isValidBinding()) {
      if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) {
        scope.problemReporter().redefineArgument(this);
      } else {
        boolean isSpecialArgument = false;
        if (existingVariable instanceof FieldBinding) {
          if (scope.isInsideConstructor()) {
            isSpecialArgument = true; // constructor argument
          } else {
            AbstractMethodDeclaration methodDecl = scope.referenceMethod();
            if (methodDecl != null && CharOperation.prefixEquals(SET, methodDecl.selector)) {
              isSpecialArgument = true; // setter argument
            }
          }
        }
        scope.problemReporter().localVariableHiding(this, existingVariable, isSpecialArgument);
      }
    }

    if (this.binding == null) {
      this.binding = new LocalVariableBinding(this, typeBinding, this.modifiers, true);
    } else if (!this.binding.type.isValidBinding()) {
      AbstractMethodDeclaration methodDecl = scope.referenceMethod();
      if (methodDecl != null) {
        MethodBinding methodBinding = methodDecl.binding;
        if (methodBinding != null) {
          methodBinding.tagBits |= TagBits.HasUnresolvedArguments;
        }
      }
    }
    scope.addLocalVariable(this.binding);
    resolveAnnotations(scope, this.annotations, this.binding);
    // true stand for argument instead of just local
    this.binding.declaration = this;
    this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
  }