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

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


    if (!targetType.isValidBinding())
      return null;
    ParameterizedTypeBinding withWildCards = InferenceContext18.parameterizedWithWildcard(targetType);
    if (withWildCards != null) {
      if (!argumentTypesElided)
        return new InferenceContext18(blockScope).inferFunctionalInterfaceParameterization(this, blockScope, withWildCards);
      else
        return findGroundTargetTypeForElidedLambda(blockScope, withWildCards);
    }
    return targetType;
  }
View Full Code Here


        (int) messageSend.nameSourcePosition);
      return;
    case ProblemReasons.ParameterizedMethodExpectedTypeProblem:
      // FIXME(stephan): construct suitable message (https://bugs.eclipse.org/404675)
      problemMethod = (ProblemMethodBinding) method;
      InferenceContext18 inferenceContext = problemMethod.inferenceContext;
      if (inferenceContext != null && inferenceContext.outerContext != null) {
        // problem relates to a nested inference context, let the outer handle it:
        inferenceContext.outerContext.addProblemMethod(problemMethod);
        return;
      }
View Full Code Here

  final CompilerOptions compilerOptions = scope.compilerOptions();
  if (compilerOptions.sourceLevel >= ClassFileConstants.JDK1_8 && this.binding instanceof ParameterizedGenericMethodBinding && this.binding.isValidBinding()) {
    if (!compilerOptions.postResolutionRawTypeCompatibilityCheck)
      return;
    ParameterizedGenericMethodBinding pgmb = (ParameterizedGenericMethodBinding) this.binding;
    InferenceContext18 ctx = getInferenceContext(pgmb);
    if (ctx == null || ctx.stepCompleted < InferenceContext18.BINDINGS_UPDATED)
      return;
    int length = pgmb.typeArguments == null ? 0 : pgmb.typeArguments.length;
    boolean sawRawType = false;
    for (int i = 0;  i < length; i++) {
View Full Code Here

}

@Override
public TypeBinding checkAgainstFinalTargetType(TypeBinding targetType, Scope scope) {
  if (this.binding instanceof ParameterizedGenericMethodBinding) {
    InferenceContext18 ctx = getInferenceContext((ParameterizedMethodBinding) this.binding);
    if (ctx != null && ctx.stepCompleted < InferenceContext18.TYPE_INFERRED) {
      this.expectedType = targetType;
      MethodBinding updatedBinding = ctx.inferInvocationType(this, (ParameterizedGenericMethodBinding) this.binding);
      if (updateBindings(updatedBinding, targetType)) {
        ASTNode.resolvePolyExpressionArguments(this, updatedBinding, scope);
      }
    }
  }
View Full Code Here

      && getInferenceContext((ParameterizedGenericMethodBinding) this.binding) != null;
}
public boolean updateBindings(MethodBinding updatedBinding, TypeBinding targetType) {
  boolean hasUpdate = this.binding != updatedBinding;
  if (this.inferenceContexts != null) {
    InferenceContext18 ctx = (InferenceContext18)this.inferenceContexts.removeKey(this.binding);
    if (ctx != null && updatedBinding instanceof ParameterizedGenericMethodBinding) {
      this.inferenceContexts.put(updatedBinding, ctx);
      // solution may have come from an outer inference, mark now that this (inner) is done (but not deep inners):
      hasUpdate |= ctx.registerSolution(targetType, updatedBinding);
    }
  }
  this.binding = updatedBinding;
  this.resolvedType = updatedBinding.returnType;
  return hasUpdate;
View Full Code Here

public InnerInferenceHelper innerInferenceHelper() {
  return this.innerInferenceHelper;
}
// -- Interface InvocationSite: --
public InferenceContext18 freshInferenceContext(Scope scope) {
  return new InferenceContext18(scope, this.arguments, this);
}
View Full Code Here

    return this.arguments;
  }
  public boolean updateBindings(MethodBinding updatedBinding, TypeBinding targetType) {
    boolean hasUpdate = this.binding != updatedBinding;
    if (this.inferenceContexts != null) {
      InferenceContext18 ctx = (InferenceContext18)this.inferenceContexts.removeKey(this.binding);
      if (ctx != null && updatedBinding instanceof ParameterizedGenericMethodBinding) {
        this.inferenceContexts.put(updatedBinding, ctx);
        // solution may have come from an outer inference, mark now that this (inner) is done (but not deep inners):
        hasUpdate |= ctx.registerSolution(targetType, updatedBinding);
      }
    }
    this.binding = updatedBinding;
    return hasUpdate;
  }
View Full Code Here

    return this.innerInferenceHelper;
  }

  // -- interface InvocationSite: --
  public InferenceContext18 freshInferenceContext(Scope scope) {
    return new InferenceContext18(scope, this.arguments, this);
  }
View Full Code Here

    } else {
      candidateMethod = null;
    }
    if (candidateMethod != null) {
      boolean variableArity = candidateMethod.isVarargs();
      InferenceContext18 infCtx = null;
      if (candidateMethod instanceof ParameterizedMethodBinding) {
        infCtx = invocation.getInferenceContext((ParameterizedMethodBinding) candidateMethod);
        if (infCtx != null) {
          if (infCtx.stepCompleted != InferenceContext18.TYPE_INFERRED) {
            // only work in the exact state of TYPE_INFERRED
            // - below we're not yet ready
            // - above we're already done-done
            return;
          }
          variableArity &= infCtx.isVarArgs(); // TODO: if no infCtx is available, do we have to re-check if this is a varargs invocation?
        }
      } else if (invocation instanceof AllocationExpression) {
        if (((AllocationExpression)invocation).suspendedResolutionState != null)
          return; // not yet ready
      }
     
      final TypeBinding[] parameters = candidateMethod.parameters;
      Expression[] innerArguments = invocation.arguments();
      Expression [] arguments = innerArguments;
      if (infCtx == null && variableArity && parameters.length == arguments.length) { // re-check
        TypeBinding lastParam = parameters[parameters.length-1];
        Expression lastArg = arguments[arguments.length-1];
        if (lastArg.isCompatibleWith(lastParam, null)) {
          variableArity = false;
        }
      }
      for (int i = 0, length = arguments == null ? 0 : arguments.length; i < length; i++) {
        Expression argument = arguments[i];
        TypeBinding updatedArgumentType = null;
        TypeBinding parameterType = InferenceContext18.getParameter(parameters, i, variableArity);
        if (parameterType == null && problemReason != ProblemReasons.NoError)
          continue; // not much we can do without a target type, assume it only happens after some resolve error

        if (argument instanceof LambdaExpression && ((LambdaExpression) argument).hasErrors())
          continue; // don't update if inner poly has errors

        if (argument instanceof Invocation) {
          Invocation innerInvocation = (Invocation)argument;
          MethodBinding binding = innerInvocation.binding(parameterType, true, scope);
          if (binding instanceof ParameterizedGenericMethodBinding) {
            ParameterizedGenericMethodBinding parameterizedMethod = (ParameterizedGenericMethodBinding) binding;
            InferenceContext18 innerContext = innerInvocation.getInferenceContext(parameterizedMethod);
            if (innerContext != null) {
              if (!innerContext.hasResultFor(parameterType)) {
                argument.setExpectedType(parameterType);
                MethodBinding improvedBinding = innerContext.inferInvocationType(innerInvocation, parameterizedMethod);
                if (!improvedBinding.isValidBinding()) {
                  innerContext.reportInvalidInvocation(innerInvocation, improvedBinding);
                }
                if (innerInvocation.updateBindings(improvedBinding, parameterType)) {
                  resolvePolyExpressionArguments(innerInvocation, improvedBinding, scope);
                }
              } else if (innerContext.stepCompleted < InferenceContext18.BINDINGS_UPDATED) {
                innerContext.rebindInnerPolies(parameterizedMethod, innerInvocation);
              }
            }
            continue; // otherwise these have been dealt with during inner method lookup
          }
        }
View Full Code Here

        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];
View Full Code Here

TOP

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

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.