com.google.javascript.rhino.jstype.UnionType Java Examples

The following examples show how to use com.google.javascript.rhino.jstype.UnionType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Closure_103_DisambiguateProperties_t.java    From coming with MIT License 6 votes vote down vote up
private ConcreteType maybeAddAutoboxes(
    ConcreteType cType, JSType jsType, String prop) {
  jsType = jsType.restrictByNotNullOrUndefined();
  if (jsType instanceof UnionType) {
    for (JSType alt : ((UnionType) jsType).getAlternates()) {
      return maybeAddAutoboxes(cType, alt, prop);
    }
  }

  if (jsType.autoboxesTo() != null) {
    JSType autoboxed = jsType.autoboxesTo();
    return cType.unionWith(tt.getConcreteInstance((ObjectType) autoboxed));
  } else if (jsType.unboxesTo() != null) {
    return cType.unionWith(tt.getConcreteInstance((ObjectType) jsType));
  }

  return cType;
}
 
Example #2
Source File: Closure_103_DisambiguateProperties_t.java    From coming with MIT License 6 votes vote down vote up
@Override public Iterable<JSType> getTypeAlternatives(JSType type) {
  if (type.isUnionType()) {
    return ((UnionType) type).getAlternates();
  } else {
    ObjectType objType = type.toObjectType();
    if (objType != null &&
        objType.getConstructor() != null &&
        objType.getConstructor().isInterface()) {
      List<JSType> list = Lists.newArrayList();
      for (FunctionType impl
               : registry.getDirectImplementors(objType)) {
        list.add(impl.getInstanceType());
      }
      return list;
    } else {
      return null;
    }
  }
}
 
Example #3
Source File: Closure_103_DisambiguateProperties_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Invalidates the given type, so that no properties on it will be renamed.
 */
private void addInvalidatingType(JSType type) {
  type = type.restrictByNotNullOrUndefined();
  if (type instanceof UnionType) {
    for (JSType alt : ((UnionType) type).getAlternates()) {
      addInvalidatingType(alt);
    }
    return;
  }

  typeSystem.addInvalidatingType(type);
  ObjectType objType = ObjectType.cast(type);
  if (objType != null && objType.getImplicitPrototype() != null) {
    typeSystem.addInvalidatingType(objType.getImplicitPrototype());
  }
}
 
Example #4
Source File: Closure_103_DisambiguateProperties_s.java    From coming with MIT License 6 votes vote down vote up
private ConcreteType maybeAddAutoboxes(
    ConcreteType cType, JSType jsType, String prop) {
  jsType = jsType.restrictByNotNullOrUndefined();
  if (jsType instanceof UnionType) {
    for (JSType alt : ((UnionType) jsType).getAlternates()) {
      return maybeAddAutoboxes(cType, alt, prop);
    }
  }

  if (jsType.autoboxesTo() != null) {
    JSType autoboxed = jsType.autoboxesTo();
    return cType.unionWith(tt.getConcreteInstance((ObjectType) autoboxed));
  } else if (jsType.unboxesTo() != null) {
    return cType.unionWith(tt.getConcreteInstance((ObjectType) jsType));
  }

  return cType;
}
 
Example #5
Source File: Closure_103_DisambiguateProperties_s.java    From coming with MIT License 6 votes vote down vote up
@Override public Iterable<JSType> getTypeAlternatives(JSType type) {
  if (type.isUnionType()) {
    return ((UnionType) type).getAlternates();
  } else {
    ObjectType objType = type.toObjectType();
    if (objType != null &&
        objType.getConstructor() != null &&
        objType.getConstructor().isInterface()) {
      List<JSType> list = Lists.newArrayList();
      for (FunctionType impl
               : registry.getDirectImplementors(objType)) {
        list.add(impl.getInstanceType());
      }
      return list;
    } else {
      return null;
    }
  }
}
 
Example #6
Source File: Closure_103_DisambiguateProperties_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Invalidates the given type, so that no properties on it will be renamed.
 */
private void addInvalidatingType(JSType type) {
  type = type.restrictByNotNullOrUndefined();
  if (type instanceof UnionType) {
    for (JSType alt : ((UnionType) type).getAlternates()) {
      addInvalidatingType(alt);
    }
    return;
  }

  typeSystem.addInvalidatingType(type);
  ObjectType objType = ObjectType.cast(type);
  if (objType != null && objType.getImplicitPrototype() != null) {
    typeSystem.addInvalidatingType(objType.getImplicitPrototype());
  }
}
 
Example #7
Source File: TypeExpressionParser.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
private void caseUnionType(UnionType type, boolean filterVoid) {
  com.github.jsdossier.proto.UnionType.Builder unionType =
      currentExpression().getUnionTypeBuilder();

  Set<TypeExpression> alternateTypes = new LinkedHashSet<>();
  for (JSType alternate : type.getAlternates()) {
    TypeExpression.Builder alternateType = TypeExpression.newBuilder();

    expressions.addLast(alternateType);
    alternate.visit(this);
    expressions.removeLast();

    if (TypeExpression.NodeTypeCase.UNION_TYPE.equals(alternateType.getNodeTypeCase())) {
      alternateTypes.addAll(alternateType.getUnionType().getTypeList());
    } else {
      alternateTypes.add(alternateType.build());
    }
  }

  if (filterVoid) {
    alternateTypes.remove(VOID_TYPE);
  }

  unionType.addAllType(UNION_ORDERING.sortedCopy(alternateTypes));
  if (unionType.getTypeCount() == 1) {
    currentExpression().clearUnionType();
    currentExpression().mergeFrom(unionType.getType(0));
  }
}
 
Example #8
Source File: TypeExpressionParser.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
private void caseInstanceType(String displayName, ObjectType type) {
  TypeExpression.Builder expression = currentExpression();

  com.github.jsdossier.proto.UnionType.Builder unionType = null;
  if (type.isNullable()) {
    unionType = expression.getUnionTypeBuilder();
    expression = unionType.addTypeBuilder();
  }

  com.github.jsdossier.proto.NamedType.Builder namedType =
      createNamedType(type.getConstructor());
  if (namedType == null) {
    com.github.jsdossier.proto.NamedType link =
        linkFactory.createNativeExternLink(type.getReferenceName());
    if (link == null) {
      expression.setNamedType(linkFactory.resolveTypeReference(displayName));
    } else {
      expression.setNamedType(link);
    }
  } else {
    expression.setNamedType(namedType);
  }

  if (unionType != null && type.isNullable()) {
    unionType.addTypeBuilder().setNullType(true);
  }
}
 
Example #9
Source File: ChainableReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #10
Source File: SemanticReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  if (target.isUnknownType()) {
    return type;
  }

  FunctionType funcTarget = target.toMaybeFunctionType();
  if (funcTarget.hasInstanceType()) {
    return type.getRestrictedUnion(funcTarget.getInstanceType());
  }

  return null;
}
 
Example #11
Source File: Closure_19_ChainableReverseAbstractInterpreter_s.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #12
Source File: Closure_19_ChainableReverseAbstractInterpreter_t.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #13
Source File: Closure_103_DisambiguateProperties_t.java    From coming with MIT License 5 votes vote down vote up
@Override public ImmutableSet<JSType> getTypesToSkipForType(JSType type) {
  type = type.restrictByNotNullOrUndefined();
  if (type instanceof UnionType) {
    Set<JSType> types = Sets.newHashSet(type);
    for (JSType alt : ((UnionType) type).getAlternates()) {
      types.addAll(getTypesToSkipForTypeNonUnion(type));
    }
    return ImmutableSet.copyOf(types);
  }
  return ImmutableSet.copyOf(getTypesToSkipForTypeNonUnion(type));
}
 
Example #14
Source File: Closure_103_DisambiguateProperties_s.java    From coming with MIT License 5 votes vote down vote up
@Override public ImmutableSet<JSType> getTypesToSkipForType(JSType type) {
  type = type.restrictByNotNullOrUndefined();
  if (type instanceof UnionType) {
    Set<JSType> types = Sets.newHashSet(type);
    for (JSType alt : ((UnionType) type).getAlternates()) {
      types.addAll(getTypesToSkipForTypeNonUnion(type));
    }
    return ImmutableSet.copyOf(types);
  }
  return ImmutableSet.copyOf(getTypesToSkipForTypeNonUnion(type));
}
 
Example #15
Source File: Closure_7_ChainableReverseAbstractInterpreter_s.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #16
Source File: DeclarationGenerator.java    From clutz with MIT License 5 votes vote down vote up
private void visitUnionType(UnionType ut, boolean inOptionalPosition) {

      Collection<JSType> alts = ut.getAlternates();

      // When visiting an optional function argument or optional field (`foo?` syntax),
      // TypeScript will augment the provided type with an union of undefined, i.e. `foo?: T` will
      // means defacto `foo` has type `T | undefined` in the body.
      // Skip explicitly emitting the undefined union in such cases.
      if (inOptionalPosition) {
        alts = Collections2.filter(alts, input -> !input.isVoidType());
      }
      if (alts.size() == 0) {
        // If the only type was "undefined" and it got filtered, emit it explicitly.
        emit("undefined");
        return;
      }
      if (alts.size() == 1) {
        visitType(alts.iterator().next());
        return;
      }
      Iterator<JSType> it = alts.iterator();
      while (it.hasNext()) {
        // See https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#a-grammar
        // UnionType:
        // UnionOrIntersectionOrPrimaryType | IntersectionOrPrimaryType
        visitTypeAsPrimary(it.next());
        if (it.hasNext()) {
          emit("|");
        }
      }
    }
 
Example #17
Source File: Closure_7_ChainableReverseAbstractInterpreter_t.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #18
Source File: Cardumen_0024_s.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #19
Source File: Cardumen_0024_t.java    From coming with MIT License 5 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  JSType restricted = null;
  for (JSType alternate : type.getAlternates()) {
    JSType restrictedAlternate = alternate.visit(this);
    if (restrictedAlternate != null) {
      if (restricted == null) {
        restricted = restrictedAlternate;
      } else {
        restricted = restrictedAlternate.getLeastSupertype(restricted);
      }
    }
  }
  return restricted;
}
 
Example #20
Source File: DeclarationGenerator.java    From clutz with MIT License 5 votes vote down vote up
private void visitRecordType(ObjectType type) {
  visitedRecordTypes.add(type);
  emit("{");
  Iterator<String> it = getEmittablePropertyNames(type).iterator();
  while (it.hasNext()) {

    String propName = it.next();
    JSType propType = type.getPropertyType(propName);

    if (visitedRecordTypes.contains(propType)) {
      emitComment("Unsupported circular reference for prop name: " + propName);
      continue;
    }

    if (isValidJSProperty(propName)) {
      emit(propName);
    } else {
      emit("'" + propName + "'");
    }
    UnionType unionType = propType.toMaybeUnionType();
    if (unionType != null && unionType.getAlternates().stream().anyMatch(JSType::isVoidType)) {
      emit("?");

      visitTypeDeclaration(propType, false, true);
    } else {
      visitTypeDeclaration(propType, false, false);
    }

    if (it.hasNext()) {
      emit(",");
    }
  }
  emit("}");
  visitedRecordTypes.remove(type);
}
 
Example #21
Source File: ChainableReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  return type.getRestrictedUnion(getNativeType(NULL_TYPE));
}
 
Example #22
Source File: Closure_112_TypeInference_t.java    From coming with MIT License 4 votes vote down vote up
private void maybeResolveTemplatedType(
    JSType paramType,
    JSType argType,
    Map<TemplateType, JSType> resolvedTypes) {
  if (paramType.isTemplateType()) {
    // @param {T}
    resolvedTemplateType(
        resolvedTypes, paramType.toMaybeTemplateType(), argType);
  } else if (paramType.isUnionType()) {
    // @param {Array.<T>|NodeList|Arguments|{length:number}}
    UnionType unionType = paramType.toMaybeUnionType();
    for (JSType alernative : unionType.getAlternates()) {
      maybeResolveTemplatedType(alernative, argType, resolvedTypes);
    }
  } else if (paramType.isFunctionType()) {
    FunctionType paramFunctionType = paramType.toMaybeFunctionType();
    FunctionType argFunctionType = argType
        .restrictByNotNullOrUndefined()
        .collapseUnion()
        .toMaybeFunctionType();
    if (argFunctionType != null && argFunctionType.isSubtype(paramType)) {
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getTypeOfThis(),
          argFunctionType.getTypeOfThis(), resolvedTypes);
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getReturnType(),
          argFunctionType.getReturnType(), resolvedTypes);
      // infer from parameter types of the function type
      maybeResolveTemplateTypeFromNodes(
          paramFunctionType.getParameters(),
          argFunctionType.getParameters(), resolvedTypes);
    }
  } else if (paramType.isTemplatizedType()) {
    // @param {Array.<T>}
    ObjectType referencedParamType = paramType
        .toMaybeTemplatizedType()
        .getReferencedType();
    JSType argObjectType = argType
        .restrictByNotNullOrUndefined()
        .collapseUnion();

    if (argObjectType.isSubtype(referencedParamType)) {
      // If the argument type is a subtype of the parameter type, resolve any
      // template types amongst their templatized types.
      TemplateTypeMap paramTypeMap = paramType.getTemplateTypeMap();
      TemplateTypeMap argTypeMap = argObjectType.getTemplateTypeMap();
      for (TemplateType key : paramTypeMap.getTemplateKeys()) {
        maybeResolveTemplatedType(
            paramTypeMap.getTemplateType(key),
            argTypeMap.getTemplateType(key),
            resolvedTypes);
      }
    }
  }
}
 
Example #23
Source File: Closure_112_TypeInference_s.java    From coming with MIT License 4 votes vote down vote up
private void maybeResolveTemplatedType(
    JSType paramType,
    JSType argType,
    Map<TemplateType, JSType> resolvedTypes) {
  if (paramType.isTemplateType()) {
    // @param {T}
    resolvedTemplateType(
        resolvedTypes, paramType.toMaybeTemplateType(), argType);
  } else if (paramType.isUnionType()) {
    // @param {Array.<T>|NodeList|Arguments|{length:number}}
    UnionType unionType = paramType.toMaybeUnionType();
    for (JSType alernative : unionType.getAlternates()) {
      maybeResolveTemplatedType(alernative, argType, resolvedTypes);
    }
  } else if (paramType.isFunctionType()) {
    FunctionType paramFunctionType = paramType.toMaybeFunctionType();
    FunctionType argFunctionType = argType
        .restrictByNotNullOrUndefined()
        .collapseUnion()
        .toMaybeFunctionType();
    if (argFunctionType != null && argFunctionType.isSubtype(paramType)) {
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getTypeOfThis(),
          argFunctionType.getTypeOfThis(), resolvedTypes);
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getReturnType(),
          argFunctionType.getReturnType(), resolvedTypes);
      // infer from parameter types of the function type
      maybeResolveTemplateTypeFromNodes(
          paramFunctionType.getParameters(),
          argFunctionType.getParameters(), resolvedTypes);
    }
  } else if (paramType.isTemplatizedType()) {
    // @param {Array.<T>}
    ObjectType referencedParamType = paramType
        .toMaybeTemplatizedType()
        .getReferencedType();
    JSType argObjectType = argType
        .restrictByNotNullOrUndefined()
        .collapseUnion();

    if (argObjectType.isSubtype(referencedParamType)) {
      // If the argument type is a subtype of the parameter type, resolve any
      // template types amongst their templatized types.
      TemplateTypeMap paramTypeMap = paramType.getTemplateTypeMap();
      TemplateTypeMap argTypeMap = argObjectType.getTemplateTypeMap();
      for (TemplateType key : paramTypeMap.getTemplateKeys()) {
        maybeResolveTemplatedType(
            paramTypeMap.getTemplateType(key),
            argTypeMap.getTemplateType(key),
            resolvedTypes);
      }
    }
  }
}
 
Example #24
Source File: TypeInference.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private void maybeResolveTemplatedType(
    JSType paramType,
    JSType argType,
    Map<TemplateType, JSType> resolvedTypes) {
  if (paramType.isTemplateType()) {
    // @param {T}
    resolvedTemplateType(
        resolvedTypes, paramType.toMaybeTemplateType(), argType);
  } else if (paramType.isUnionType()) {
    // @param {Array.<T>|NodeList|Arguments|{length:number}}
    UnionType unionType = paramType.toMaybeUnionType();
    for (JSType alernative : unionType.getAlternates()) {
      maybeResolveTemplatedType(alernative, argType, resolvedTypes);
    }
  } else if (paramType.isFunctionType()) {
    FunctionType paramFunctionType = paramType.toMaybeFunctionType();
    FunctionType argFunctionType = argType
        .restrictByNotNullOrUndefined()
        .collapseUnion()
        .toMaybeFunctionType();
    if (argFunctionType != null && argFunctionType.isSubtype(paramType)) {
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getTypeOfThis(),
          argFunctionType.getTypeOfThis(), resolvedTypes);
      // infer from return type of the function type
      maybeResolveTemplatedType(
          paramFunctionType.getReturnType(),
          argFunctionType.getReturnType(), resolvedTypes);
      // infer from parameter types of the function type
      maybeResolveTemplateTypeFromNodes(
          paramFunctionType.getParameters(),
          argFunctionType.getParameters(), resolvedTypes);
    }
  } else if (paramType.isParameterizedType()) {
    ParameterizedType paramObjectType = paramType.toMaybeParameterizedType();
    JSType typeParameter = paramObjectType.getParameterType();
    Preconditions.checkNotNull(typeParameter);
    if (typeParameter != null) {
      // @param {Array.<T>}
      ObjectType argObjectType = argType
          .restrictByNotNullOrUndefined()
          .collapseUnion()
          .toMaybeParameterizedType();
      if (argObjectType != null && argObjectType.isSubtype(paramType)) {
        JSType argTypeParameter = argObjectType.getParameterType();
        Preconditions.checkNotNull(argTypeParameter);
        maybeResolveTemplatedType(
            typeParameter, argTypeParameter, resolvedTypes);
      }
    }
  }
}
 
Example #25
Source File: SemanticReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  return applyCommonRestriction(type);
}
 
Example #26
Source File: ChainableReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  return type.getRestrictedUnion(getNativeType(VOID_TYPE));
}
 
Example #27
Source File: Closure_19_ChainableReverseAbstractInterpreter_s.java    From coming with MIT License 4 votes vote down vote up
@Override
public JSType caseUnionType(UnionType type) {
  return type.getRestrictedUnion(getNativeType(VOID_TYPE));
}
 
Example #28
Source File: TypeParameterCollector.java    From jsinterop-generator with Apache License 2.0 4 votes vote down vote up
@Override
public Void caseUnionType(UnionType type) {
  type.getAlternates().forEach(t -> t.visit(this));

  return null;
}
 
Example #29
Source File: TypeCollectionPass.java    From js-dossier with Apache License 2.0 4 votes vote down vote up
@Override
public Object caseUnionType(UnionType type) {
  return null;
}
 
Example #30
Source File: TypeExpressionParser.java    From js-dossier with Apache License 2.0 4 votes vote down vote up
@Override
public Void caseFunctionType(FunctionType type) {
  if ("Function".equals(type.getReferenceName())) {
    currentExpression().getNamedTypeBuilder().setName("Function");
    return null;
  }

  com.github.jsdossier.proto.FunctionType.Builder functionType =
      currentExpression().getFunctionTypeBuilder();

  if (type.isConstructor()) {
    functionType.setIsConstructor(true);
    expressions.addLast(functionType.getInstanceTypeBuilder());
    type.getTypeOfThis().visit(this);
    expressions.removeLast();

  } else if (!type.getTypeOfThis().isUnknownType()
      || type.getTypeOfThis() instanceof NamedType) {
    expressions.addLast(functionType.getInstanceTypeBuilder());
    type.getTypeOfThis().visit(this);
    expressions.removeLast();
  }

  for (Node node : type.getParameters()) {
    TypeExpression.Builder parameterType = functionType.addParameterBuilder();
    expressions.addLast(parameterType);

    if (node.isVarArgs()) {
      parameterType.setIsVarargs(true);
    }

    if (node.getJSType() != null) {
      if (node.getJSType().isUnionType()) {
        caseUnionType((UnionType) node.getJSType(), node.isOptionalArg());
      } else {
        node.getJSType().visit(this);
      }
    }

    if (node.isOptionalArg()) {
      // Not sure if this is possible, but varargs implies optional and we only permit one
      // bit to be set.
      if (!parameterType.getIsVarargs()) {
        parameterType.setIsOptional(true);
      }
    }

    expressions.removeLast();
  }

  if (type.getReturnType() != null && !type.isConstructor()) {
    expressions.addLast(functionType.getReturnTypeBuilder());
    type.getReturnType().visit(this);
    expressions.removeLast();
  }
  return null;
}