-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Description
Suppose, we want to create wrapper for some class by extending existing wrapper, e.g. wrapper for ArrayDeque
based on UtLinkedList
. The problem is that we can't call functions with super syntax like super.add
, so it increases copy-paste. It happens because our method overriding mechanism resolves the call of a super method to the current method itself, so infinite recursion occurs.
public class InheritedWrapper extends BaseWrapper {
public void add(Object o) {
// some stuff
super.add(o); // this resolves to InheritedWrapper::add instead of BaseWrapper::add
}
}
Expected behavior
It's possible to extend an existing wrapper and call methods of ancestor with super. This wrapper works as expected.
Context
Wrappers are our own easy-to-analyze implementations of existing classes with the same functionality. See UtLinkedList
, ListWrapper
, etc.
Related functions: Traverser::overrideInvocation
, Traverser::invokeSpecial
, Traverser::commonInvokePart
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status