Package com.google.dart.engine.type

Examples of com.google.dart.engine.type.FunctionType


      isGetter = accessorElement.isGetter();
      isSetter = accessorElement.isSetter();
    }
    String executableElementName = executableElement.getName();

    FunctionType overridingFT = executableElement.getType();
    FunctionType overriddenFT = overriddenExecutable.getType();
    InterfaceType enclosingType = enclosingClass.getType();
    overriddenFT = inheritanceManager.substituteTypeArgumentsInMemberFromInheritance(
        overriddenFT,
        executableElementName,
        enclosingType);

    if (overridingFT == null || overriddenFT == null) {
      return false;
    }

    Type overridingFTReturnType = overridingFT.getReturnType();
    Type overriddenFTReturnType = overriddenFT.getReturnType();
    Type[] overridingNormalPT = overridingFT.getNormalParameterTypes();
    Type[] overriddenNormalPT = overriddenFT.getNormalParameterTypes();
    Type[] overridingPositionalPT = overridingFT.getOptionalParameterTypes();
    Type[] overriddenPositionalPT = overriddenFT.getOptionalParameterTypes();
    Map<String, Type> overridingNamedPT = overridingFT.getNamedParameterTypes();
    Map<String, Type> overriddenNamedPT = overriddenFT.getNamedParameterTypes();

    // CTEC.INVALID_OVERRIDE_REQUIRED, CTEC.INVALID_OVERRIDE_POSITIONAL and CTEC.INVALID_OVERRIDE_NAMED
    if (overridingNormalPT.length > overriddenNormalPT.length) {
      errorReporter.reportErrorForNode(
          StaticWarningCode.INVALID_OVERRIDE_REQUIRED,
View Full Code Here


            redirectedType.getDisplayName());
        return true;
      }
      return false;
    }
    FunctionType redirectedType = redirectedElement.getType();
    Type redirectedReturnType = redirectedType.getReturnType();
    //
    // Report specific problem when return type is incompatible
    //
    FunctionType constructorType = node.getElement().getType();
    Type constructorReturnType = constructorType.getReturnType();
    if (!redirectedReturnType.isAssignableTo(constructorReturnType)) {
      errorReporter.reportErrorForNode(
          StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE,
          redirectedConstructor,
          redirectedReturnType,
View Full Code Here

   * @see CompileTimeErrorCode#RETURN_IN_GENERATIVE_CONSTRUCTOR
   * @see StaticWarningCode#RETURN_WITHOUT_VALUE
   * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE
   */
  private boolean checkForAllReturnStatementErrorCodes(ReturnStatement node) {
    FunctionType functionType = enclosingFunction == null ? null : enclosingFunction.getType();
    Type expectedReturnType = functionType == null ? DynamicTypeImpl.getInstance()
        : functionType.getReturnType();
    Expression returnExpression = node.getExpression();
    // RETURN_IN_GENERATIVE_CONSTRUCTOR
    boolean isGenerativeConstructor = enclosingFunction instanceof ConstructorElement
        && !((ConstructorElement) enclosingFunction).isFactory();
    if (isGenerativeConstructor) {
View Full Code Here

      // Check to see if an element was found in the superclass chain with the correct name.
      if (elt != null) {

        // Reference the types, if any are null then continue.
        InterfaceType enclosingType = enclosingClass.getType();
        FunctionType concreteType = elt.getType();
        FunctionType requiredMemberType = executableElt.getType();
        if (enclosingType == null || concreteType == null || requiredMemberType == null) {
          continue;
        }

        // Some element was found in the superclass chain that matches the name of the required
        // member.
        // If it is not abstract and it is the correct one (types match- the version of this method
        // that we have has the correct number of parameters, etc), then this class has a valid
        // implementation of this method, so skip it.
        if ((elt instanceof MethodElement && !((MethodElement) elt).isAbstract())
            || (elt instanceof PropertyAccessorElement && !((PropertyAccessorElement) elt).isAbstract())) {
          // Since we are comparing two function types, we need to do the appropriate type
          // substitutions first ().
          FunctionType foundConcreteFT = inheritanceManager.substituteTypeArgumentsInMemberFromInheritance(
              concreteType,
              memberName,
              enclosingType);
          FunctionType requiredMemberFT = inheritanceManager.substituteTypeArgumentsInMemberFromInheritance(
              requiredMemberType,
              memberName,
              enclosingType);
          if (foundConcreteFT.isSubtypeOf(requiredMemberFT)) {
            continue;
View Full Code Here

      if (!type.isAssignableTo(boolType)) {
        errorReporter.reportErrorForNode(StaticTypeWarningCode.NON_BOOL_EXPRESSION, expression);
        return true;
      }
    } else if (type instanceof FunctionType) {
      FunctionType functionType = (FunctionType) type;
      if (functionType.getTypeArguments().length == 0
          && !functionType.getReturnType().isAssignableTo(boolType)) {
        errorReporter.reportErrorForNode(StaticTypeWarningCode.NON_BOOL_EXPRESSION, expression);
        return true;
      }
    }
    return false;
View Full Code Here

   *
   * @param propertyAccessorElement
   * @return The type of the given getter.
   */
  private Type getGetterType(PropertyAccessorElement propertyAccessorElement) {
    FunctionType functionType = propertyAccessorElement.getType();
    if (functionType != null) {
      return functionType.getReturnType();
    } else {
      return null;
    }
  }
View Full Code Here

    if (inheritancePath == null || inheritancePath.isEmpty()) {
      // TODO(jwren) log analysis engine error
      return baseFunctionType;
    }
    FunctionType functionTypeToReturn = baseFunctionType;
    // loop backward through the list substituting as we go:
    while (!inheritancePath.isEmpty()) {
      InterfaceType lastType = inheritancePath.removeLast();
      Type[] parameterTypes = lastType.getElement().getType().getTypeArguments();
      Type[] argumentTypes = lastType.getTypeArguments();
      functionTypeToReturn = functionTypeToReturn.substitute(argumentTypes, parameterTypes);
    }
    return functionTypeToReturn;
  }
View Full Code Here

          for (int i = 0; i < numOfEltsWithMatchingNames; i++) {
            executableElementTypes[i] = elements[i].getType();
          }
          ArrayList<Integer> subtypesOfAllOtherTypesIndexes = new ArrayList<Integer>(1);
          for (int i = 0; i < numOfEltsWithMatchingNames; i++) {
            FunctionType subtype = executableElementTypes[i];
            if (subtype == null) {
              continue;
            }
            boolean subtypeOfAllTypes = true;
            for (int j = 0; j < numOfEltsWithMatchingNames && subtypeOfAllTypes; j++) {
              if (i != j) {
                if (!subtype.isSubtypeOf(executableElementTypes[j])) {
                  subtypeOfAllTypes = false;
                  break;
                }
              }
            }
View Full Code Here

    if (element instanceof PropertyAccessorElement) {
      //
      // This is really a function expression invocation.
      //
      // TODO(brianwilkerson) Consider the possibility of re-writing the AST.
      FunctionType getterType = ((PropertyAccessorElement) element).getType();
      if (getterType != null) {
        Type returnType = getterType.getReturnType();
        if (!isExecutableType(returnType)) {
          return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
        }
      }
    } else if (element instanceof ExecutableElement) {
      return null;
    } else if (element instanceof MultiplyDefinedElement) {
      // The error has already been reported
      return null;
    } else if (element == null && target instanceof SuperExpression) {
      // TODO(jwren) We should split the UNDEFINED_METHOD into two error codes, this one, and
      // a code that describes the situation where the method was found, but it was not
      // accessible from the current library.
      return StaticTypeWarningCode.UNDEFINED_SUPER_METHOD;
    } else {
      //
      // This is really a function expression invocation.
      //
      // TODO(brianwilkerson) Consider the possibility of re-writing the AST.
      if (element instanceof PropertyInducingElement) {
        PropertyAccessorElement getter = ((PropertyInducingElement) element).getGetter();
        FunctionType getterType = getter.getType();
        if (getterType != null) {
          Type returnType = getterType.getReturnType();
          if (!isExecutableType(returnType)) {
            return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
          }
        }
      } else if (element instanceof VariableElement) {
View Full Code Here

      Element element) {
    if (element instanceof PropertyAccessorElement) {
      //
      // This is an invocation of the call method defined on the value returned by the getter.
      //
      FunctionType getterType = ((PropertyAccessorElement) element).getType();
      if (getterType != null) {
        Type getterReturnType = getterType.getReturnType();
        if (getterReturnType instanceof InterfaceType) {
          MethodElement callMethod = ((InterfaceType) getterReturnType).lookUpMethod(
              FunctionElement.CALL_METHOD_NAME,
              definingLibrary);
          if (callMethod != null) {
            return resolveArgumentsToFunction(false, argumentList, callMethod);
          }
        } else if (getterReturnType instanceof FunctionType) {
          ParameterElement[] parameters = ((FunctionType) getterReturnType).getParameters();
          return resolveArgumentsToParameters(false, argumentList, parameters);
        }
      }
    } else if (element instanceof ExecutableElement) {
      return resolveArgumentsToFunction(false, argumentList, (ExecutableElement) element);
    } else if (element instanceof VariableElement) {
      VariableElement variable = (VariableElement) element;
      Type type = promoteManager.getStaticType(variable);
      if (type instanceof FunctionType) {
        FunctionType functionType = (FunctionType) type;
        ParameterElement[] parameters = functionType.getParameters();
        return resolveArgumentsToParameters(false, argumentList, parameters);
      } else if (type instanceof InterfaceType) {
        // "call" invocation
        MethodElement callMethod = ((InterfaceType) type).lookUpMethod(
            FunctionElement.CALL_METHOD_NAME,
View Full Code Here

TOP

Related Classes of com.google.dart.engine.type.FunctionType

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.