-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
This would be epic to have. Java itself had a problem with forcing the implementing class to implement the abstract methods, and solved it with default interface implementations. Sometimes, multiple inheritance is necessary to have. For example, I have a sea of crisscrossing is-a relationships to handle, with a ton of things like the following:
class Identifier extends Node implements Assignable, ImportPatternEntry,
IdentifierLike, PropertyLike, Subtypable {
// stuff...
}
class MemberExpression extends Node implements Assignable,
IdentifierLike, PropertyLike, Subtypable {
// stuff...
}
It's not pretty, but I also have to check many of these relationships at runtime as well. I can't use traditional single inheritance for this, either, because none of these are mutually exclusive. I would love to have ways to set default properties on these classes, to where I don't have to make a build script to generate all this. (I have 30+ base classes and 20+ interfaces with very intertwined relationships like the above.)
What I was thinking of was something like this:
interface IFoo {
bar = true;
}
class Foo {}
class Bar implements IFoo {}
new Foo().bar; // undefined
new Bar().bar; // true