2 * Detect classes that should have overridden members of their parent
8 * virtual NS_MUST_OVERRIDE void f();
12 * struct A : S { virtual void f(); }; // ok
13 * struct B : S { virtual NS_MUST_OVERRIDE void f(); }; // also ok
15 * struct C : S { virtual void g(); }; // ERROR: must override f()
16 * struct D : S { virtual void f(int); }; // ERROR: different overload
17 * struct E : A { }; // ok: A's definition of f() is good for subclasses
18 * struct F : B { }; // ERROR: B's definition of f() is still must-override
20 * We don't care if you define the method or not.
23 function get_must_overrides(cls)
26 for each (let base in cls.bases)
27 for each (let m in base.type.members)
28 if (hasAttribute(m, 'NS_must_override'))
34 function process_type(t)
36 if (t.isIncomplete || (t.kind != 'class' && t.kind != 'struct'))
39 let mos = get_must_overrides(t);
40 for each (let m in t.members) {
41 let mos_m = mos[m.shortName]
42 if (mos_m && signaturesMatch(mos_m, m))
43 delete mos[m.shortName];
46 for each (let u in mos)
47 error(t.kind + " " + t.name + " must override " + u.name, t.loc);