Description
The front-end adds a default constructor to an anonymous mixin application class if it introduces no forwarding constructors, which only happens if the superclass has no accessible generative constructors.
In that case, the default constructors super-invocation of super()
is guaranteed to be an error.
The specification is not saying anything directly about this.
The spec says which forwarding constructors a mixin application class is given, but not anything about what to do if that is zero constructors.
It says that if a class declares no constructors, it gets a default constructor.
That should probably only apply to class declarations, and not to anonymous mixin declarations, which can't declare constructors at all, and which gets forwarding constructors added instead.
It's not because mixing in a mixin on a class with no accessible generative constructors is useful. It's equivalent to implementing the mixin's interface because there is no way to extend a mixin application class with no generative constructor and make an instantiable class.
Still, it shouldn't hurt. If you have a non-base
mixin declaration, you can mix it in or implement it, and you get the same interface in both cases.
If you have a base
mixin declaration and you create a class that cannot have an instantiable subclass, can only be used as an interface, so if you do use it, you're inside the same library, and you could just have implemented the base mixin
directly.
In any case, we should be explicit about what compilers should do in this case, and I recommend not adding a constructor that's going to be an immediate compile-time error.