From 1208f36f7af96985b2ccfc2903825c022cfc8820 Mon Sep 17 00:00:00 2001 From: nykwono Date: Tue, 6 Oct 2026 20:07:48 -0400 Subject: [PATCH 1/2] Always use topASC when checking for private variables --- polymod/hscript/_internal/Interp.hx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/polymod/hscript/_internal/Interp.hx b/polymod/hscript/_internal/Interp.hx index edd2f1f7..f0d826fa 100644 --- a/polymod/hscript/_internal/Interp.hx +++ b/polymod/hscript/_internal/Interp.hx @@ -2224,7 +2224,7 @@ class Interp checkTypeForDeprecation(name); return PolymodEnum.tryBuild(name, f); } - try + try { return get(fieldTarget(e), f); } @@ -3455,13 +3455,17 @@ class Interp } else if (Std.isOfType(o, PolymodScriptClass)) { - var ref:PolymodAbstractScriptClass = cast(o, PolymodAbstractScriptClass); + // We use the topASC value when checking script classes + // As there's a chance the function we're referencing wasn't found in the parent but in a superclass instead. + var ref:PolymodAbstractScriptClass = cast(o, PolymodAbstractScriptClass).getMostTopASC(); + var proxyTopASC:PolymodAbstractScriptClass = _proxy?.getMostTopASC(); + var clsName:String = proxyTopASC?.fullyQualifiedName ?? getClassFullyQualifiedName(); - if (ref.fullyQualifiedName == getClassFullyQualifiedName()) + if (ref.fullyQualifiedName == clsName) return true; // If this script class shares the same superclasses with this class we're in (inheritance) then we can access it if the field is any of those. - var superClasses:Array = PolymodScriptClass.getSuperClasses(getClassDecl()) ?? []; + var superClasses:Array = PolymodScriptClass.getSuperClasses(proxyTopASC?._c ?? getClassDecl()) ?? []; var inheritatedSuperClasses:Array = [ref.fullyQualifiedName].concat(PolymodScriptClass.getSuperClasses(ref._c)).filter((superCls:String) -> return superClasses.contains(superCls)); var superClass:Dynamic = ref.superClass; @@ -3509,7 +3513,7 @@ class Interp else { // We're checking for fields from within a regular class. - var superClasses:Array = PolymodScriptClass.getSuperClasses(getClassDecl()) ?? []; + var superClasses:Array = PolymodScriptClass.getSuperClasses(_proxy?.getMostTopASC()._c ?? getClassDecl()) ?? []; var inheritatedSuperClasses:Array = [Util.getTypeNameOf(o)].concat(Util.getSuperClasses(o) ?? []).filter((superCls:String) -> return superClasses.contains(superCls)); for (cls in inheritatedSuperClasses) From acb11d113e2078f553c10e5f4e509f4d42430dbb Mon Sep 17 00:00:00 2001 From: nykwono Date: Tue, 6 Oct 2026 20:10:15 -0400 Subject: [PATCH 2/2] Always use PolymodStaticClassReference.instantiate when creating scripted classes --- polymod/hscript/_internal/Interp.hx | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/polymod/hscript/_internal/Interp.hx b/polymod/hscript/_internal/Interp.hx index f0d826fa..029f1d82 100644 --- a/polymod/hscript/_internal/Interp.hx +++ b/polymod/hscript/_internal/Interp.hx @@ -219,17 +219,8 @@ class Interp var packagedClass = getClassDecl().pkg.join(".") + "." + cl; if (_scriptClassDescriptors.exists(packagedClass)) { - // OVERRIDE CHANGE: Create a PolymodScriptClass instead of a ScriptClass - var clsDescriptor:ClassDecl = findScriptClassDescriptor(packagedClass); - var ctorField:Null = clsDescriptor.fields.find((f) -> f.name == 'new'); - if (clsDescriptor != getClassDecl() && ctorField?.access.contains(APrivate)) - { - error(EPrivateConstructor(clsRef.cls.name)); - return null; - } - - var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(clsDescriptor, args); - return proxy; + var clsRef = PolymodStaticClassReference.tryBuild(packagedClass); + if (clsRef != null) return tryBuildClass(clsRef, args); } } @:privateAccess @@ -238,16 +229,8 @@ class Interp var importedClass:ClassImport = getClassDecl().imports.get(cl); if (_scriptClassDescriptors.exists(importedClass.fullPath)) { - // OVERRIDE CHANGE: Create a PolymodScriptClass instead of a ScriptClass - var clsDescriptor:ClassDecl = findScriptClassDescriptor(importedClass.fullPath); - var ctorField:Null = clsDescriptor.fields.find((f) -> f.name == 'new'); - if (clsDescriptor != getClassDecl() && ctorField?.access.contains(APrivate)) - { - error(EPrivateConstructor(clsRef.cls.name)); - return null; - } - var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(clsDescriptor, args); - return proxy; + var clsRef = PolymodStaticClassReference.tryBuild(importedClass.fullPath); + if (clsRef != null) return tryBuildClass(clsRef, args); } // Ignore importedClass.enm as enums cannot be instantiated.