From 1742f070e3fcc0dee4274f1d0368996f13f51aeb Mon Sep 17 00:00:00 2001 From: TechnikTil Date: Fri, 1 May 2026 12:13:03 -0600 Subject: [PATCH] Fix Scripted Class Extending not working with multiple layers of scripted classes Signed-off-by: TechnikTil --- .../hscript/_internal/HScriptedClassMacro.hx | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/polymod/hscript/_internal/HScriptedClassMacro.hx b/polymod/hscript/_internal/HScriptedClassMacro.hx index 496b351c..3a0323e5 100644 --- a/polymod/hscript/_internal/HScriptedClassMacro.hx +++ b/polymod/hscript/_internal/HScriptedClassMacro.hx @@ -995,18 +995,26 @@ class HScriptedClassMacro {_asc.callFunction($v{funcName}, [$a{func_callArgs}]); return;}) : (macro return _asc.callFunction($v{funcName}, [$a{func_callArgs}])) } } - // If another scripted class is being extended, call if the function exists there - else if ((_asc.superClass is polymod.hscript._internal.PolymodScriptClass) - && _asc.superClass.hasScriptFunction($v{funcName})) + else { - var _super = (_asc.superClass : polymod.hscript._internal.PolymodScriptClass); - $ + // If another scripted class is being extended, call if the function exists there + var _super = _asc.superClass; + while (_super is polymod.hscript._internal.PolymodScriptClass) { - doesReturnVoid ? (macro + var _scriptSuper = (_super : polymod.hscript._internal.PolymodScriptClass); + if (_scriptSuper.hasScriptFunction($v{funcName})) + { + $ { - _super.callFunction($v{funcName}, [$a{func_callArgs}]); - return; - }) : (macro return _super.callFunction($v{funcName}, [$a{func_callArgs}])) + doesReturnVoid ? (macro + { + _scriptSuper.callFunction($v{funcName}, [$a{func_callArgs}]); + return; + }) : (macro return _scriptSuper.callFunction($v{funcName}, [$a{func_callArgs}])) + } + } + + _super = _scriptSuper.superClass; } } }