Skip to content

Commit daeb812

Browse files
nykwonoAbnormalPoof
authored andcommitted
Always use PolymodStaticClassReference.instantiate when creating scripted classes
1 parent 003993c commit daeb812

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

‎polymod/hscript/_internal/Interp.hx‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,8 @@ class Interp
219219
var packagedClass = getClassDecl().pkg.join(".") + "." + cl;
220220
if (_scriptClassDescriptors.exists(packagedClass))
221221
{
222-
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a ScriptClass
223-
var clsDescriptor:ClassDecl = findScriptClassDescriptor(packagedClass);
224-
var ctorField:Null<FieldDecl> = clsDescriptor.fields.find((f) -> f.name == 'new');
225-
if (clsDescriptor != getClassDecl() && ctorField?.access.contains(APrivate))
226-
{
227-
error(EPrivateConstructor(clsRef.cls.name));
228-
return null;
229-
}
230-
231-
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(clsDescriptor, args);
232-
return proxy;
222+
var clsRef = PolymodStaticClassReference.tryBuild(packagedClass);
223+
if (clsRef != null) return tryBuildClass(clsRef, args);
233224
}
234225
}
235226
@:privateAccess
@@ -238,16 +229,8 @@ class Interp
238229
var importedClass:ClassImport = getClassDecl().imports.get(cl);
239230
if (_scriptClassDescriptors.exists(importedClass.fullPath))
240231
{
241-
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a ScriptClass
242-
var clsDescriptor:ClassDecl = findScriptClassDescriptor(importedClass.fullPath);
243-
var ctorField:Null<FieldDecl> = clsDescriptor.fields.find((f) -> f.name == 'new');
244-
if (clsDescriptor != getClassDecl() && ctorField?.access.contains(APrivate))
245-
{
246-
error(EPrivateConstructor(clsRef.cls.name));
247-
return null;
248-
}
249-
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(clsDescriptor, args);
250-
return proxy;
232+
var clsRef = PolymodStaticClassReference.tryBuild(importedClass.fullPath);
233+
if (clsRef != null) return tryBuildClass(clsRef, args);
251234
}
252235

253236
// Ignore importedClass.enm as enums cannot be instantiated.

0 commit comments

Comments
 (0)