@mcclure
Latest commit d95c4d2 Sep 22, 2020 History
* Allow inheritance of _init from more than one level up

Currently _init is exempted from "fat inheritance", and _init inheritance works by a strange workaround where the base class exactly one level up is checked for _init at constructor time. This appears to be done so that :super() can work properly, but it means that _init cannot be inherited from a grandparent.

This patch adds a _parent_with_init field to all relevant classes which points to the most recent ancestor with an _init implementation. This simplifies both __call and _class and might actually be a performance improvement (it removes a loop).

* Add changelog line and tests for grandparent _init

* Add tests: Invocation of a : function inherited from a grandparent; and ensure :super() fails when it ought to fail.

* Prevent a stack overflow when a particular class :super() edge case is hit.

This causes the "createK" test in test-class.lua to fail with a "null function" error instead of a stack overflow.

* Improved fix for :super infinite loop problem (avoid second rawset)
5 contributors

Users who have contributed to this file

@stevedonovan @Tieske @theypsilon @jvprat @mcclure