-
-
Notifications
You must be signed in to change notification settings - Fork 694
Open
Description
In some code architecture, it is necessary for things to work correctly to always call the super method when you override it, and it can causes several issues when it's forgotten by some devs. Given this is general programming feature not specific to a given app or framework, I propose we introduce a @:callSuper metadata at the compiler level to enforce this.
class A {
@:callSuper function init() { }
}
class B extends A {
override function init() {
// error super.init() was not called
}
}
class C extends A {
var initDone:Bool;
override function init() {
if( initDone ) return;
trace("initializing");
initDone = true;
super.init();
// we do not check all code paths to allow such patterns
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels