It's not possible.
The reason it's not possible is that it breaks abstraction.
When you look at class C extend B
, all you need to know about B
is which signatures its members has and which interfaces it implements. As long as that stays effectively the same, your valid code will keep working.
Consider what would happen if the author of B
decided to make themselves a helper base-class:
abstract class _BaseB extends A {
String get _myName;
@override
void hello() {
print(_myName);
}
}
class B extends _BaseB {
@override
String get _myName => "B";
}
That's a perfectly valid refactoring. The resulting class B
has all the same members and implements all the same interfaces (and also _BaseB
, but it's private so nobody can see that).
The C
class above would keep working if all it does is to call super.hello()
. If it had a way to ask for super.super.hello()
, that might no longer be valid.
Similarly if the B
class was changed to:
class B implements A {
@override
void hello() {
print("B");
}
}
(changing extends
to implements
), then all methods of B
works the same as before and it implements the same interfaces. Again, there is no visible differences to the users of the B
class.
But if you could call something like A.super.hello()
to reach the A
class's hello
method, then that would now break because that method isn't in the B
class at all.
So, by restricting super.hello()
to only call methods on the precise class you write as the superclass, you are prevented from introducing dependencies on the implementation of B
, dependencies which would make otherwise valid refactorings into breaking changes.