Allow subclasses to determine the A- and B-types.

The default code assumes direct subclasses that extend this class with
explicit types. This fails, however, if the subclasses have generic types
which are used in the extends clause. Therefore the type determination
code has been factored out into a separate method which can be overridden
by subclasses if desired.