Class BaseTypeVisitor.OverrideChecker
- Direct Known Subclasses:
GuiEffectVisitor.GuiEffectOverrideChecker
- Enclosing class:
- BaseTypeVisitor<Factory extends GenericAnnotatedTypeFactory<?,
?, ?, ?>>
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.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final boolean
True ifoverriderTree
is a MEMBER_REFERENCE.protected final AnnotatedTypeMirror.AnnotatedExecutableType
The type of the overridden method.protected final AnnotatedTypeMirror
The teturn type of the overridden method.protected final AnnotatedTypeMirror.AnnotatedDeclaredType
The supertype that declares the overridden method.protected final AnnotatedTypeMirror.AnnotatedExecutableType
The type of the overriding method.protected final AnnotatedTypeMirror
The return type of the overriding method.protected final Tree
The declaration of an overriding method.protected final AnnotatedTypeMirror
The subtype that declares the overriding method. -
Constructor Summary
ConstructorDescriptionOverrideChecker
(Tree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror overriderType, AnnotatedTypeMirror overriderReturnType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, AnnotatedTypeMirror overriddenReturnType) Create an OverrideChecker. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Perform the check.protected boolean
Issue an "override.receiver" error if the receiver override is not valid.
-
Field Details
-
overriderTree
The declaration of an overriding method. -
isMethodReference
protected final boolean isMethodReferenceTrue ifoverriderTree
is a MEMBER_REFERENCE. -
overrider
The type of the overriding method. -
overriderType
The subtype that declares the overriding method. -
overridden
The type of the overridden method. -
overriddenType
The supertype that declares the overridden method. -
overriddenReturnType
The teturn type of the overridden method. -
overriderReturnType
The return type of the overriding method.
-
-
Constructor Details
-
OverrideChecker
public OverrideChecker(Tree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror overriderType, AnnotatedTypeMirror overriderReturnType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, AnnotatedTypeMirror overriddenReturnType) Create an OverrideChecker.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.
- Parameters:
overriderTree
- the AST node of the overriding method or method referenceoverrider
- the type of the overriding methodoverriderType
- the type enclosing the overrider method, usually an AnnotatedDeclaredType; for Method References may be something elseoverriderReturnType
- 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
-
-
Method Details
-
checkOverride
public boolean checkOverride()Perform the check.- Returns:
- true if the override is allowed
-
checkReceiverOverride
protected boolean checkReceiverOverride()Issue an "override.receiver" error if the receiver override is not valid.- Returns:
- true if the override is legal
-