Skip to content

Commit 7c203b5

Browse files
Fix for static class import resolution.
1 parent 0ea4c1b commit 7c203b5

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

polymod/hscript/_internal/PolymodInterpEx.hx

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ class PolymodInterpEx extends Interp
2525
function getClassDecl():PolymodClassDeclEx {
2626
if (_classDeclOverride != null) {
2727
return _classDeclOverride;
28-
} else {
28+
} else if (_proxy != null) {
2929
return _proxy._c;
30+
} else {
31+
return null;
3032
}
3133
}
3234

@@ -62,40 +64,37 @@ class PolymodInterpEx extends Interp
6264
var clsRef = PolymodStaticClassReference.tryBuild(cl);
6365
if (clsRef != null) return clsRef.instantiate(args);
6466

65-
if (_proxy != null)
67+
@:privateAccess
68+
if (getClassDecl()?.pkg != null)
6669
{
6770
@:privateAccess
68-
if (getClassDecl().pkg != null)
71+
var packagedClass = getClassDecl().pkg.join(".") + "." + cl;
72+
if (_scriptClassDescriptors.exists(packagedClass))
6973
{
70-
@:privateAccess
71-
var packagedClass = getClassDecl().pkg.join(".") + "." + cl;
72-
if (_scriptClassDescriptors.exists(packagedClass))
73-
{
74-
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a hscript.ScriptClass
75-
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(_scriptClassDescriptors.get(packagedClass), args);
76-
return proxy;
77-
}
74+
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a hscript.ScriptClass
75+
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(_scriptClassDescriptors.get(packagedClass), args);
76+
return proxy;
7877
}
78+
}
7979

80-
@:privateAccess
81-
if (getClassDecl().imports != null && getClassDecl().imports.exists(cl))
80+
@:privateAccess
81+
if (getClassDecl()?.imports != null && getClassDecl().imports.exists(cl))
82+
{
83+
var importedClass:PolymodClassImport = getClassDecl().imports.get(cl);
84+
if (_scriptClassDescriptors.exists(importedClass.fullPath))
8285
{
83-
var importedClass:PolymodClassImport = getClassDecl().imports.get(cl);
84-
if (_scriptClassDescriptors.exists(importedClass.fullPath))
85-
{
86-
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a hscript.ScriptClass
87-
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(_scriptClassDescriptors.get(importedClass.fullPath), args);
88-
return proxy;
89-
}
86+
// OVERRIDE CHANGE: Create a PolymodScriptClass instead of a hscript.ScriptClass
87+
var proxy:PolymodAbstractScriptClass = new PolymodScriptClass(_scriptClassDescriptors.get(importedClass.fullPath), args);
88+
return proxy;
89+
}
9090

91-
// Ignore importedClass.enm as enums cannot be instantiated.
92-
var c = importedClass.cls;
93-
if (c == null)
94-
{
95-
errorEx(EBlacklistedModule(importedClass.fullPath));
96-
} else {
97-
return Type.createInstance(c, args);
98-
}
91+
// Ignore importedClass.enm as enums cannot be instantiated.
92+
var c = importedClass.cls;
93+
if (c == null)
94+
{
95+
errorEx(EBlacklistedModule(importedClass.fullPath));
96+
} else {
97+
return Type.createInstance(c, args);
9998
}
10099
}
101100

@@ -918,13 +917,15 @@ class PolymodInterpEx extends Interp
918917
// OVERRIDE CHANGE: Allow access to modules for calling static functions.
919918

920919
// Attempt to access an import.
921-
if (_proxy != null)
920+
if (getClassDecl() != null)
922921
{
923922
var importedClass:PolymodClassImport = getClassDecl().imports.get(id);
924923
if (importedClass != null) {
925924
if (importedClass.cls != null) return importedClass.cls;
926925
if (importedClass.enm != null) return importedClass.enm;
927926
}
927+
} else {
928+
trace('No proxy, trying to resolve: ${id}');
928929
}
929930

930931
// Allow access to scripted classes for calling static functions.

polymod/hscript/_internal/PolymodScriptClassMacro.hx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class PolymodScriptClassMacro {
100100
var polymodScriptClassClassType:ClassType = MacroUtil.getClassType('polymod.hscript._internal.PolymodScriptClassMacro');
101101
polymodScriptClassClassType.meta.add('hscriptedClasses', hscriptedClassEntries, Context.currentPos());
102102
polymodScriptClassClassType.meta.add('abstractImpls', abstractImplEntries, Context.currentPos());
103-
104-
polymodScriptClassClassType.meta.add('hello', [macro $v{'world'}], Context.currentPos());
105103
}
106104
#end
107105

0 commit comments

Comments
 (0)