public final class FunctionType extends Object implements Serializable
ObjectType instances.| Type | Property and Description |
|---|---|
FunctionType |
transformByApply
Returns a FunctionType representing the 'apply' property of this
function.
|
FunctionType |
transformByCall
Returns a FunctionType representing the 'call' property of this
function (i.e.
|
| Modifier and Type | Method and Description |
|---|---|
StringBuilder |
appendTo(StringBuilder builder,
ToStringContext ctx) |
boolean |
equals(Object obj) |
JSType |
getFormalType(int argpos)
Returns the formal parameter in the given (0-indexed) position,
or null if the position is past the end of the parameter list.
|
JSType |
getInstanceTypeOfCtor()
If this type is a constructor (e.g.
|
int |
getMaxArity()
Returns the maximum number of parameters accepted by this function,
or Integer.MAX_VALUE for a function with rest parameters (effectively
infinite).
|
int |
getMaxArityWithoutRestFormals()
Returns the maximum number of parameters accepted by this function,
not counting rest parameters.
|
int |
getMinArity()
Returns the minimum number of parameters accepted by this function.
|
JSType |
getOuterVarPrecondition(String name)
Returns the type of the closed-over variable of the given name,
or null if the named variable is not in the closure.
|
JSType |
getRestFormalsType()
Returns the type of this function's rest parameter.
|
JSType |
getReturnType() |
JSType |
getSuperPrototype()
Returns the prototype object of the superclass, or null if there is
no superclass.
|
JSType |
getThisType()
Returns the 'this' type of the function, or the 'new' type for a
constructor.
|
List<String> |
getTypeParameters()
Returns all the non-instantiated type parameter names.
|
int |
hashCode() |
boolean |
hasRestFormals() |
FunctionType |
instantiateGenerics(Map<String,JSType> typeMap)
Returns a FunctionType with generic type parameters instantiated as
concrete types using typeMap.
|
FunctionType |
instantiateGenericsFromArgumentTypes(JSType recvtype,
List<JSType> argTypes)
Given concrete types for the arguments, unify with the formals to create
a type map, and then instantiate this function as usual, by calling
substituteParametricGenerics(java.util.Map<java.lang.String, com.google.javascript.jscomp.newtypes.JSType>). |
boolean |
isAbstract() |
boolean |
isConstructorOfAbstractClass() |
boolean |
isGeneric()
Returns true if this function has any non-instantiated type parameters.
|
boolean |
isInterfaceDefinition()
Returns true if this is a constructor for a single interface, i.e.
|
boolean |
isLoose()
Returns true if this function type is "loose".
|
boolean |
isOptionalArg(int i)
Returns true if the
ith parameter is an optional parameter. |
boolean |
isQmarkFunction()
Returns true if this function is the common QMARK_FUNCTION type
(function(...?): ?), determined by reference equality.
|
boolean |
isRequiredArg(int i)
Returns true if the
ith parameter is required. |
boolean |
isSomeConstructorOrInterface()
Returns true if this type is some sort of constructor, i.e.
|
boolean |
isTopFunction()
Returns true if this function is either version (loose or not) of the
top function (which takes all bottoms and returns top).
|
boolean |
isUniqueConstructor()
Returns true if this is a constructor for a single class, i.e.
|
boolean |
isValidOverride(FunctionType other)
Returns true if this function is a valid override of other.
|
DeclaredFunctionType |
toDeclaredFunctionType()
Returns this function type as a
DeclaredFunctionType. |
String |
toString() |
FunctionType |
transformByApplyProperty()
Returns a FunctionType representing the 'apply' property of this
function.
|
FunctionType |
transformByCallProperty()
Returns a FunctionType representing the 'call' property of this
function (i.e.
|
public FunctionType transformByCallProperty
public FunctionType transformByApplyProperty
public boolean isLoose()
function f(g) { return g(5) - 2; }. Here, g is a loose number→number
function. A loose function type may have required formal parameters that are bottom.public boolean isAbstract()
public boolean isConstructorOfAbstractClass()
public boolean isTopFunction()
public boolean isSomeConstructorOrInterface()
isUniqueConstructor() and
isInterfaceDefinition().public boolean isUniqueConstructor()
public boolean isInterfaceDefinition()
public JSType getSuperPrototype()
IllegalStateException - if this is not a unique constructor.public boolean isQmarkFunction()
public boolean hasRestFormals()
public JSType getRestFormalsType()
IllegalStateException - if there is no rest parameter.public JSType getFormalType(int argpos)
IllegalStateException - if this is the top function (rather than returning bottom).public JSType getReturnType()
public JSType getOuterVarPrecondition(String name)
IllegalStateException - if this is the top function.public int getMinArity()
IllegalStateException - if this is the top function, which has
effectively-infinite minimum arity.public int getMaxArity()
IllegalStateException - if this is the top function.public int getMaxArityWithoutRestFormals()
IllegalStateException - if this is the top function.public boolean isRequiredArg(int i)
ith parameter is required.public boolean isOptionalArg(int i)
ith parameter is an optional parameter.public JSType getInstanceTypeOfCtor()
public JSType getThisType()
public FunctionType transformByCallProperty()
public FunctionType transformByApplyProperty()
public DeclaredFunctionType toDeclaredFunctionType()
DeclaredFunctionType. While
DeclaredFunctionType allows incomplete types (i.e. null formals or
returns), this function always returns a complete type. This should
only be called from GlobalTypeInfo.IllegalStateException - if this function is loose.public boolean isValidOverride(FunctionType other)
public boolean isGeneric()
public List<String> getTypeParameters()
public FunctionType instantiateGenerics(Map<String,JSType> typeMap)
substituteNominalGenerics(java.util.Map<java.lang.String, com.google.javascript.jscomp.newtypes.JSType>), which operates on the free type
variables found in formal parameters and returns.public FunctionType instantiateGenericsFromArgumentTypes(JSType recvtype, List<JSType> argTypes)
substituteParametricGenerics(java.util.Map<java.lang.String, com.google.javascript.jscomp.newtypes.JSType>).IllegalStateException - if this is not a generic function.public StringBuilder appendTo(StringBuilder builder, ToStringContext ctx)
Copyright © 2009-2017 Google. All Rights Reserved.