Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.TypeBinding


/**
* @see org.eclipse.jdt.internal.compiler.ast.Expression#postConversionType(Scope)
*/
public TypeBinding postConversionType(Scope scope) {
  TypeBinding convertedType = this.resolvedType;
  if (this.valueCast != null)
    convertedType = this.valueCast;
  int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4;
  switch (runtimeType) {
    case T_boolean :
View Full Code Here


        scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
      }
    } else {
      // handle indirect inheritance thru variable secondary bound
      // receiver may receive generic cast, as part of implicit conversion
      TypeBinding oldReceiverType = this.actualReceiverType;
      this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
      this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
      if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
        this.bits |= NeedReceiverGenericCast;
      }
    }
  } else {
    // static message invoked through receiver? legal but unoptimal (optional warning).
    if (!(this.receiver.isImplicitThis() || this.receiver.isSuper() || receiverIsType)) {
      scope.problemReporter().nonStaticAccessToStaticMethod(this, this.binding);
    }
    if (!this.receiver.isImplicitThis() && this.binding.declaringClass != this.actualReceiverType) {
      scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
    }
  }
  if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
    this.bits |= ASTNode.Unchecked;
  }

  //-------message send that are known to fail at compile time-----------
  if (this.binding.isAbstract()) {
    if (this.receiver.isSuper()) {
      scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, this.binding);
    }
    // abstract private methods cannot occur nor abstract static............
  }
  if (isMethodUseDeprecated(this.binding, scope, true))
    scope.problemReporter().deprecatedMethod(this.binding, this);

  // from 1.5 source level on, array#clone() returns the array type (but binding still shows Object)
  if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) {
    this.resolvedType = this.actualReceiverType;
  } else {
    TypeBinding returnType;
    if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6
      returnType = this.binding.returnType;
      if (returnType != null) {
        returnType = scope.environment().convertToRawType(returnType.erasure(), true);
      }
    } else {
      returnType = this.binding.returnType;
      if (returnType != null) {
        returnType = returnType.capture(scope, this.sourceEnd);
      }
    }
    this.resolvedType = returnType;
  }
  if (this.receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
View Full Code Here

    new String[]{ new String(leafComponentType.shortReadableName())},
    location.sourceStart,
    location.sourceEnd);
}
public void illegalInstanceOfGenericType(TypeBinding checkedType, ASTNode location) {
  TypeBinding erasedType = checkedType.leafComponentType().erasure();
  StringBuffer recommendedFormBuffer = new StringBuffer(10);
  if (erasedType instanceof ReferenceBinding) {
    ReferenceBinding referenceBinding = (ReferenceBinding) erasedType;
    recommendedFormBuffer.append(referenceBinding.qualifiedSourceName());
  } else {
    recommendedFormBuffer.append(erasedType.sourceName());
  }
  int count = erasedType.typeVariables().length;
  if (count > 0) {
    recommendedFormBuffer.append('<');
    for (int i = 0; i < count; i++) {
      if (i > 0) {
        recommendedFormBuffer.append(',');
View Full Code Here

    case ProblemReasons.ParameterBoundMismatch :
      problemConstructor = (ProblemMethodBinding) targetConstructor;
      ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
      shownConstructor = substitutedConstructor.original();
      int augmentedLength = problemConstructor.parameters.length;
      TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
      TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
      TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
      System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);
      this.handle(
        IProblem.GenericConstructorTypeArgumentMismatch,
        new String[] {
                new String(shownConstructor.declaringClass.sourceName()),
                typesAsString(shownConstructor, false),
                new String(shownConstructor.declaringClass.readableName()),
                typesAsString(invocationArguments, false),
                new String(inferredTypeArgument.readableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, false) },
        new String[] {
                new String(shownConstructor.declaringClass.sourceName()),
                typesAsString(shownConstructor, true),
                new String(shownConstructor.declaringClass.shortReadableName()),
                typesAsString(invocationArguments, true),
                new String(inferredTypeArgument.shortReadableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, true) },
        sourceStart,
        sourceEnd);
      return;
View Full Code Here

    if (isRecoveredName(ref.token)) return;
  }
  int id = IProblem.UndefinedField;
  switch (field.problemId()) {
    case ProblemReasons.NotFound :
      TypeBinding declaringClass = field.declaringClass;
      if (declaringClass != null && (declaringClass.tagBits & TagBits.HasMissingType) != 0) {
        this.handle(
            IProblem.UndefinedType,
            new String[] {new String(field.declaringClass.readableName())},
            new String[] {new String(field.declaringClass.shortReadableName())},
View Full Code Here

    case ProblemReasons.ParameterBoundMismatch :
      problemMethod = (ProblemMethodBinding) method;
      ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
      shownMethod = substitutedMethod.original();
      int augmentedLength = problemMethod.parameters.length;
      TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
      TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
      TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
      System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
      this.handle(
        IProblem.GenericMethodTypeArgumentMismatch,
        new String[] {
                new String(shownMethod.selector),
                typesAsString(shownMethod, false),
                new String(shownMethod.declaringClass.readableName()),
                typesAsString(invocationArguments, false),
                new String(inferredTypeArgument.readableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, false) },
        new String[] {
                new String(shownMethod.selector),
                typesAsString(shownMethod, true),
                new String(shownMethod.declaringClass.shortReadableName()),
                typesAsString(invocationArguments, true),
                new String(inferredTypeArgument.shortReadableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, true) },
        (int) (messageSend.nameSourcePosition >>> 32),
        (int) messageSend.nameSourcePosition);
      return;
View Full Code Here

public void invalidType(ASTNode location, TypeBinding type) {
  if (type instanceof ReferenceBinding) {
    if (isRecoveredName(((ReferenceBinding)type).compoundName)) return;
  }
  else if (type instanceof ArrayBinding) {
    TypeBinding leafType = ((ArrayBinding)type).leafComponentType;
    if (leafType instanceof ReferenceBinding) {
      if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return;
    }
  }

  if (type.isParameterizedType()) {
    List missingTypes = type.collectMissingTypes(null);
    if (missingTypes != null) {
      ReferenceContext savedContext = this.referenceContext;
      for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) {
        try {
          invalidType(location, (TypeBinding) iterator.next());
        } finally {
          this.referenceContext = savedContext;
        }
      }
      return;
    }
  }
  int id = IProblem.UndefinedType; // default
  switch (type.problemId()) {
    case ProblemReasons.NotFound :
      id = IProblem.UndefinedType;
      break;
    case ProblemReasons.NotVisible :
      id = IProblem.NotVisibleType;
      break;
    case ProblemReasons.Ambiguous :
      id = IProblem.AmbiguousType;
      break;
    case ProblemReasons.InternalNameProvided :
      id = IProblem.InternalTypeNameProvided;
      break;
    case ProblemReasons.InheritedNameHidesEnclosingName :
      id = IProblem.InheritedTypeHidesEnclosingName;
      break;
    case ProblemReasons.NonStaticReferenceInStaticContext :
      id = IProblem.NonStaticTypeFromStaticInvocation;
      break;
    case ProblemReasons.IllegalSuperTypeVariable :
      id = IProblem.IllegalTypeVariableSuperReference;
      break;
    case ProblemReasons.NoError : // 0
    default :
      needImplementation(location); // want to fail to see why we were here...
      break;
  }

  int end = location.sourceEnd;
  if (location instanceof QualifiedNameReference) {
    QualifiedNameReference ref = (QualifiedNameReference) location;
    if (isRecoveredName(ref.tokens)) return;
    if (ref.indexOfFirstFieldBinding >= 1)
      end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
  } else if (location instanceof ParameterizedQualifiedTypeReference) {
    // must be before instanceof ArrayQualifiedTypeReference
    ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location;
    if (isRecoveredName(ref.tokens)) return;
    if (type instanceof ReferenceBinding) {
      char[][] name = ((ReferenceBinding) type).compoundName;
      end = (int) ref.sourcePositions[name.length - 1];
    }
  } else if (location instanceof ArrayQualifiedTypeReference) {
    ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
    if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return;
    TypeBinding leafType = type.leafComponentType();
    if (leafType instanceof ReferenceBinding) {
      char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved
      end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1];
    } else {
      long[] positions = arrayQualifiedTypeReference.sourcePositions;
View Full Code Here

      problemConstructor = (ProblemMethodBinding) targetConstructor;
      ParameterizedGenericMethodBinding substitutedConstructor = (ParameterizedGenericMethodBinding) problemConstructor.closestMatch;
      shownConstructor = substitutedConstructor.original();

      int augmentedLength = problemConstructor.parameters.length;
      TypeBinding inferredTypeArgument = problemConstructor.parameters[augmentedLength-2];
      TypeVariableBinding typeParameter = (TypeVariableBinding) problemConstructor.parameters[augmentedLength-1];
      TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
      System.arraycopy(problemConstructor.parameters, 0, invocationArguments, 0, augmentedLength-2);

      this.handle(
        IProblem.JavadocGenericConstructorTypeArgumentMismatch,
        new String[] {
                new String(shownConstructor.declaringClass.sourceName()),
                typesAsString(shownConstructor, false),
                new String(shownConstructor.declaringClass.readableName()),
                typesAsString(invocationArguments, false),
                new String(inferredTypeArgument.readableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, false) },
        new String[] {
                new String(shownConstructor.declaringClass.sourceName()),
                typesAsString(shownConstructor, true),
                new String(shownConstructor.declaringClass.shortReadableName()),
                typesAsString(invocationArguments, true),
                new String(inferredTypeArgument.shortReadableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, true) },
        severity,
        sourceStart,
        sourceEnd);
View Full Code Here

      if (severity == ProblemSeverities.Ignore) return;
      problemMethod = (ProblemMethodBinding) method;
      ParameterizedGenericMethodBinding substitutedMethod = (ParameterizedGenericMethodBinding) problemMethod.closestMatch;
      shownMethod = substitutedMethod.original();
      int augmentedLength = problemMethod.parameters.length;
      TypeBinding inferredTypeArgument = problemMethod.parameters[augmentedLength-2];
      TypeVariableBinding typeParameter = (TypeVariableBinding) problemMethod.parameters[augmentedLength-1];
      TypeBinding[] invocationArguments = new TypeBinding[augmentedLength-2]; // remove extra info from the end
      System.arraycopy(problemMethod.parameters, 0, invocationArguments, 0, augmentedLength-2);
      this.handle(
        IProblem.JavadocGenericMethodTypeArgumentMismatch,
        new String[] {
                new String(shownMethod.selector),
                typesAsString(shownMethod, false),
                new String(shownMethod.declaringClass.readableName()),
                typesAsString(invocationArguments, false),
                new String(inferredTypeArgument.readableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, false) },
        new String[] {
                new String(shownMethod.selector),
                typesAsString(shownMethod, true),
                new String(shownMethod.declaringClass.shortReadableName()),
                typesAsString(invocationArguments, true),
                new String(inferredTypeArgument.shortReadableName()),
                new String(typeParameter.sourceName),
                parameterBoundAsString(typeParameter, true) },
        severity,
        (int) (messageSend.nameSourcePosition >>> 32),
        (int) messageSend.nameSourcePosition);
View Full Code Here

}

public void missingDeprecatedAnnotationForType(TypeDeclaration type) {
  int severity = computeSeverity(IProblem.TypeMissingDeprecatedAnnotation);
  if (severity == ProblemSeverities.Ignore) return;
  TypeBinding binding = type.binding;
  this.handle(
    IProblem.TypeMissingDeprecatedAnnotation,
    new String[] {new String(binding.readableName()), },
    new String[] {new String(binding.shortReadableName()),},
    severity,
    type.sourceStart,
    type.sourceEnd);
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.TypeBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.