public class BaseTypeVisitor.OverrideChecker extends Object
Method references are checked similarly to method overrides, with the method reference viewed as overriding the functional interface's method.
Checks that an overriding method's return type, parameter types, and receiver type are correct with respect to the annotations on the overridden method's return type, parameter types, and receiver type.
Furthermore, any contracts on the method must satisfy behavioral subtyping, that is, postconditions must be at least as strong as the postcondition on the superclass, and preconditions must be at most as strong as the condition on the superclass.
This method returns the result of the check, but also emits error messages as a side effect.
Modifier and Type | Field and Description |
---|---|
protected Boolean |
methodReference |
protected AnnotatedTypeMirror.AnnotatedExecutableType |
overridden |
protected String |
overriddenMeth |
protected AnnotatedTypeMirror |
overriddenReturnType |
protected String |
overriddenTyp |
protected AnnotatedTypeMirror.AnnotatedDeclaredType |
overriddenType |
protected AnnotatedTypeMirror.AnnotatedExecutableType |
overrider |
protected String |
overriderMeth |
protected Tree |
overriderTree |
protected String |
overriderTyp |
protected AnnotatedTypeMirror |
overridingReturnType |
protected AnnotatedTypeMirror |
overridingType |
Constructor and Description |
---|
OverrideChecker(Tree overriderTree,
AnnotatedTypeMirror.AnnotatedExecutableType overrider,
AnnotatedTypeMirror overridingType,
AnnotatedTypeMirror overridingReturnType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
AnnotatedTypeMirror overriddenReturnType)
Create an OverrideChecker.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkOverride()
Perform the check
|
protected boolean |
checkReceiverOverride() |
protected final String overriderMeth
protected final String overriderTyp
protected final String overriddenMeth
protected final String overriddenTyp
protected final Tree overriderTree
protected final Boolean methodReference
protected final AnnotatedTypeMirror.AnnotatedExecutableType overrider
protected final AnnotatedTypeMirror overridingType
protected final AnnotatedTypeMirror.AnnotatedExecutableType overridden
protected final AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType
protected final AnnotatedTypeMirror overriddenReturnType
protected final AnnotatedTypeMirror overridingReturnType
public OverrideChecker(Tree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror overridingType, AnnotatedTypeMirror overridingReturnType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, AnnotatedTypeMirror overriddenReturnType)
Notice that the return types are passed in separately. This is to support some types of method references where the overrider's return type is not the appropriate type to check.
overriderTree
- the AST node of the overriding method or method referenceoverrider
- the type of the overriding methodoverridingType
- the type enclosing the overrider method, usually an
AnnotatedDeclaredType; for Method References may be something elseoverridingReturnType
- the return type of the overriding methodoverridden
- the type of the overridden methodoverriddenType
- the declared type enclosing the overridden methodoverriddenReturnType
- the return type of the overridden method