Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.Invocation


      c.add(new ConstraintExpressionFormula(expri, substF, ReductionResult.COMPATIBLE, ARGUMENT_CONSTRAINTS_ARE_SOFT));
    }
    if (expri instanceof FunctionalExpression) {
      c.add(new ConstraintExceptionFormula((FunctionalExpression) expri, substF));
    } else if (expri instanceof Invocation && expri.isPolyExpression()) {
      Invocation invocation = (Invocation) expri;
      MethodBinding innerMethod = invocation.binding(null, false, null);
      if (innerMethod instanceof ParameterizedGenericMethodBinding) {
        InferenceContext18 innerCtx = invocation.getInferenceContext((ParameterizedMethodBinding) innerMethod);
        if (innerCtx != null) { // otherwise innerMethod does not participate in inference
          return addConstraintsToC(invocation.arguments(), c, innerMethod.genericMethod(), innerCtx.inferenceKind);
        }
      }
    } else if (expri instanceof ConditionalExpression) {
      ConditionalExpression ce = (ConditionalExpression) expri;
      return addConstraintsToC_OneExpr(ce.valueIfTrue, c, fsi, substF, method)
View Full Code Here


    // (handles generic invocations)
    int len = this.innerPolies.size();
    for (int i = 0; i < len; i++) {
      Expression inner = (Expression) this.innerPolies.get(i);
      if (inner instanceof Invocation) {
        Invocation innerMessage = (Invocation) inner;
        TypeBinding innerTargetType = inner.expectedType(); // may be set from acceptPendingPolyArguments
        if (innerTargetType != null && !innerTargetType.isProperType(true))
          innerTargetType = null;
        MethodBinding binding = innerMessage.binding(innerTargetType, innerTargetType != null, this.scope);
        if (binding == null)
          continue;
        MethodBinding original = binding.shallowOriginal();

        // apply inference results onto the allocation type of inner diamonds:
        if (original.isConstructor() && inner.isPolyExpression()) {
          ReferenceBinding declaringClass = original.declaringClass;
          TypeBinding[] arguments = getSolutions(declaringClass.typeVariables(), innerMessage, bounds);
          declaringClass = this.environment.createParameterizedType(declaringClass, arguments, declaringClass.enclosingType());
          original = ((ParameterizedTypeBinding)declaringClass).createParameterizedMethod(original);
          inner.checkAgainstFinalTargetType(innerTargetType, this.scope)
          if (this.environment.globalOptions.isAnnotationBasedNullAnalysisEnabled)
            NullAnnotationMatching.checkForContraditions(original, innerMessage, this.scope);
        }
       
        // apply results of the combined inference onto the binding of the inner invocation:
        TypeBinding[] solutions = getSolutions(original.typeVariables(), innerMessage, bounds);
        if (solutions == null) {
          if (binding instanceof ParameterizedGenericMethodBinding) {
            InferenceContext18 innerCtx = innerMessage.getInferenceContext((ParameterizedGenericMethodBinding) binding);
            if (innerCtx != null && !binding.isValidBinding()) {
              innerCtx.reportInvalidInvocation(innerMessage, binding);
            }
          }
          continue; // inner inference not requested -> not a problem
        }
        ParameterizedGenericMethodBinding innerBinding = this.environment.createParameterizedGenericMethod(original, solutions);
       
        if (innerMessage.updateBindings(innerBinding, innerTargetType)) { // only if we are actually improving anything
          ASTNode.resolvePolyExpressionArguments(innerMessage, innerBinding, this.scope);
        }
      }
    }
    this.stepCompleted = BINDINGS_UPDATED; // we're done-done
View Full Code Here

      TypeBinding targetType = getParameter(parameterTypes, i, isVarArgs);
      if (!targetType.isProperType(true))
        targetType = Scope.substitute(substitution, targetType);
      Expression expression = this.invocationArguments[i];
      if (expression instanceof Invocation) {
        Invocation invocation = (Invocation) expression;
        if (!this.innerPolies.contains(invocation)) {
          MethodBinding method = invocation.binding(targetType, true, this.scope);
          if (method instanceof ParameterizedGenericMethodBinding) {
            ParameterizedGenericMethodBinding previousBinding = (ParameterizedGenericMethodBinding) method;
            InferenceContext18 innerCtx = invocation.getInferenceContext(previousBinding);
            if (innerCtx != null) {
              // we have a non-poly generic invocation, which needs inference but is not connected via innerPolis.
              // Finish that inner inference now (incl. binding updates):
              MethodBinding innerBinding = innerCtx.inferInvocationType(invocation, previousBinding);
              if (!innerBinding.isValidBinding()) {
                innerCtx.reportInvalidInvocation(invocation, innerBinding);
              }
              if (invocation.updateBindings(innerBinding, targetType)) { // only if we are actually improving anything
                ASTNode.resolvePolyExpressionArguments(invocation, innerBinding, this.scope);
              }
            }
          } else if(method instanceof ParameterizedMethodBinding){
            expression.checkAgainstFinalTargetType(targetType, this.scope);
View Full Code Here

      } else if (this.left instanceof AllocationExpression && this.left.isPolyExpression()) {
        // half-resolved diamond has a resolvedType, but that may not be the final word, try one more step of resolution:
              MethodBinding binding = ((AllocationExpression) this.left).binding(this.right, false, null);
              return (binding != null && binding.declaringClass.isCompatibleWith(this.right, inferenceContext.scope)) ? TRUE : FALSE;
            } else if (this.left instanceof Invocation && this.left.isPolyExpression()) {
              Invocation invoc = (Invocation) this.left;
              MethodBinding binding = invoc.binding(this.right, false, null);
              if (binding instanceof ParameterizedGenericMethodBinding) {
                ParameterizedGenericMethodBinding method = (ParameterizedGenericMethodBinding) binding;
          InferenceContext18 leftCtx = invoc.getInferenceContext(method);
                if (leftCtx.stepCompleted < InferenceContext18.TYPE_INFERRED) {
                  break proper; // fall through into nested inference below (not explicit in the spec!)
                }
              }
            }
      return FALSE;
    }
    if (!canBePolyExpression(this.left)) {
      TypeBinding exprType = this.left.resolvedType;
      if (exprType == null || !exprType.isValidBinding())
        return FALSE;
      return ConstraintTypeFormula.create(exprType, this.right, COMPATIBLE, this.isSoft);
    } else {
      // shapes of poly expressions (18.2.1)
      // - parenthesized expression : these are transparent in our AST
      if (this.left instanceof Invocation) {
        Invocation invocation = (Invocation) this.left;
        MethodBinding previousMethod = invocation.binding(this.right, false, null);
        if (previousMethod == null)    // can happen, e.g., if inside a copied lambda with ignored errors
          return null;         // -> proceed with no new constraints
        MethodBinding method = previousMethod;
        // ignore previous (inner) inference result and do a fresh start:
        // avoid original(), since we only want to discard one level of instantiation
        // (method type variables - not class type variables)!
        method = previousMethod.shallowOriginal();
        SuspendedInferenceRecord prevInvocation = inferenceContext.enterPolyInvocation(invocation, invocation.arguments());

        // Invocation Applicability Inference: 18.5.1 & Invocation Type Inference: 18.5.2
        try {
          Expression[] arguments = invocation.arguments();
          TypeBinding[] argumentTypes = arguments == null ? Binding.NO_PARAMETERS : new TypeBinding[arguments.length];
          for (int i = 0; i < argumentTypes.length; i++)
            argumentTypes[i] = arguments[i].resolvedType;
          if (previousMethod instanceof ParameterizedGenericMethodBinding) {
            // find the previous inner inference context to see what inference kind this invocation needs:
            InferenceContext18 innerCtx = invocation.getInferenceContext((ParameterizedGenericMethodBinding) previousMethod);
            if (innerCtx == null) { // no inference -> assume it wasn't really poly after all
              TypeBinding exprType = this.left.resolvedType;
              if (exprType == null || !exprType.isValidBinding())
                return FALSE;
              return ConstraintTypeFormula.create(exprType, this.right, COMPATIBLE, this.isSoft);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.Invocation

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.