C# 8 base interface's default method invocation workaround
The link in the question points to a version of the proposal copied from the proposal document in Github
The feature was cut in April 2019
Conclusion
Cut base() syntax for C# 8. We intend to bring this back in the next major release.
The design meeting doc explains that without runtime support (which wouldn't be available in time), the implementation would be workable at best for C# but not VB.NET.
If B.M is not present at run time, A.M() will be called. For base() and interfaces, this is not supported by the runtime, so the call will throw an exception instead. We'd like to add support for this in the runtime, but it is too expensive to make this release.
We have some workarounds, but they do not have the behavior we want, and are not the preferred codegen. Our implementation for C# is somewhat workable, although not exactly what we would like, but the VB implementation would be much more difficult. Moreover, the implementation for VB would require the interface implementation methods to be public API surface.
As for the infinite recursion, this
public void M()
{
((IB)this).M(); // Throws stack overflow
}
That's essentially
public void M()
{
M(); // Throws stack overflow
}
Default interface members are called the same way explicitly implemented interface methods are, through the interface. Besides, you're asking to call the method on this
, not base
.