From 4f25ab162dc5e5a67e0559887695a84fe727c510 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Wed, 26 Aug 2020 15:51:27 +0200 Subject: [PATCH] added inheritance on setGlobals --- hscript/Checker.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hscript/Checker.hx b/hscript/Checker.hx index 44a32af..1101a83 100644 --- a/hscript/Checker.hx +++ b/hscript/Checker.hx @@ -295,9 +295,17 @@ class Checker { } public function setGlobals( cl : CClass ) { - for( f in cl.fields ) - if( f.isPublic ) - setGlobal(f.name, f.params.length == 0 ? f.t : TLazy(function() return apply(f.t,f.params,[for( i in 0...f.params.length) makeMono()]))); + while( true ) { + for( f in cl.fields ) + if( f.isPublic ) + setGlobal(f.name, f.params.length == 0 ? f.t : TLazy(function() return apply(f.t,f.params,[for( i in 0...f.params.length) makeMono()]))); + if( cl.superClass == null ) + break; + cl = switch( cl.superClass ) { + case TInst(c,_): c; + default: throw "assert"; + } + } } public function removeGlobal( name : String ) {