Class CompileTimeDeclarationType
java.lang.Object
org.checkerframework.framework.util.typeinference8.types.AbstractExecutableType
org.checkerframework.framework.util.typeinference8.types.CompileTimeDeclarationType
Represents the type of the compile-time declaration of the method reference. The compile-time
declaration is the actual method referenced by the method reference. See JLS section
15.13.1 for a complete definition.
The type of a member reference is a functional interface. The function type of a member reference is the type of the single abstract method declared by the functional interface.
For example,
class MyClass {
public int compareByField(MyClass other) { ... }
}
Comparator<MyClass> func = MyClass::compareByField;
The function type is int compare(Comparator<MyClass> this, MyClass o1, MyClass o2)
whereas the type of the compile-time declaration is int compareByField(MyClass this,
MyClass other).
-
Field Summary
Fields inherited from class org.checkerframework.framework.util.typeinference8.types.AbstractExecutableType
annotatedExecutableType, context, executableType, qualifierVars, typeFactory -
Constructor Summary
ConstructorsConstructorDescriptionCompileTimeDeclarationType(AnnotatedTypeMirror.AnnotatedExecutableType annotatedExecutableType, ExecutableType executableType, MemberReferenceTree methodRef, AnnotatedTypeMirror receiver, Java8InferenceContext context) Creates a compile-time declaration type for a method reference. -
Method Summary
Modifier and TypeMethodDescriptionReturns the method reference for which this is a compile-time declaration.getParameterTypes(@Nullable Theta map, int size) Returns the formal parameter types of this executable.getReturnType(@Nullable Theta map) Returns the return type of this.Methods inherited from class org.checkerframework.framework.util.typeinference8.types.AbstractExecutableType
getAnnotatedType, getAnnotatedTypeVariables, getParameterTypes, getParameterTypes, getThrownTypes, getTypeVariables, hasTypeVariables, isVoid
-
Constructor Details
-
CompileTimeDeclarationType
public CompileTimeDeclarationType(AnnotatedTypeMirror.AnnotatedExecutableType annotatedExecutableType, ExecutableType executableType, MemberReferenceTree methodRef, AnnotatedTypeMirror receiver, Java8InferenceContext context) Creates a compile-time declaration type for a method reference.- Parameters:
annotatedExecutableType- annotated method or constructor typeexecutableType- a Java method or constructor typemethodRef- a method referencereceiver- the type of the receiver for this method referencecontext- the context
-
-
Method Details
-
getMethodRef
Returns the method reference for which this is a compile-time declaration.- Returns:
- the method reference for which this is a compile-time declaration
-
getReturnType
Description copied from class:AbstractExecutableTypeReturns the return type of this.- Specified by:
getReturnTypein classAbstractExecutableType- Parameters:
map- a mapping from type variable to inference variable, or null to treat no type variable as an inference variable- Returns:
- the return type
-
getParameterTypes
Description copied from class:AbstractExecutableTypeReturns the formal parameter types of this executable.If this invocation uses varargs, then the vararg parameter is replaced by individual parameters and the result has length
size. Otherwise,sizeis ignored and the result contains one element per declared formal parameter, plus one for the receiver if this is an unbound method reference.- Specified by:
getParameterTypesin classAbstractExecutableType- Parameters:
map- a mapping from type variable to inference variable, or null to treat no type variable as an inference variablesize- the number of parameters to return; used to expand the vararg. It is ignored if this invocation does not use varargs.- Returns:
- the formal parameter types of this executable
-