Beispiel #1
0
 public FunctionType asConstantFunctionType(MethodElement element) {
   com.google.dart.compiler.type.FunctionType functionType = element.getFunctionType();
   return typeRepository.findFunction(
       false,
       asType(true, functionType.getReturnType()),
       asTypeList(functionType.getParameterTypes()),
       asTypeMap(functionType.getNamedParameterTypes()),
       element);
 }
Beispiel #2
0
 private FunctionType asFunctionType(
     boolean nullable, com.google.dart.compiler.type.FunctionType functionType) {
   return typeRepository.findFunction(
       nullable,
       asType(true, functionType.getReturnType()),
       asTypeList(functionType.getParameterTypes()),
       asTypeMap(functionType.getNamedParameterTypes()),
       null);
 }
Beispiel #3
0
  /** @return a JsArrayLiteral listing the type arguments for the interface instance. */
  private JsExpression buildTypeArgsForFactory(
      FunctionType functionType,
      InterfaceType instanceType,
      List<? extends Type> listTypeVars,
      JsExpression contextTypeArgs) {
    if (functionType.getTypeVariables().size() == 0) {
      return null;
    }

    if (instanceType.hasDynamicTypeArgs()) {
      return translationContext.getProgram().getNullLiteral();
    }

    JsArrayLiteral arr = new JsArrayLiteral();
    for (Type type : instanceType.getArguments()) {
      JsExpression typeExpr = buildTypeLookupExpression(type, listTypeVars, contextTypeArgs);
      arr.getExpressions().add(typeExpr);
    }

    return arr;
  }