Skip to content

Commit eaaacd1

Browse files
committed
Fix a few parity issues
1 parent 15a476d commit eaaacd1

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

polymod/hscript/_internal/PolymodInterpEx.hx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,12 @@ class PolymodInterpEx extends Interp
974974
{
975975
try
976976
{
977+
#if hl
978+
// HL is a bit weird with iterators with arguments
979+
v = Reflect.callMethod(v, v.iterator, []);
980+
#else
977981
v = v.iterator();
982+
#end
978983
}
979984
catch (e:Dynamic)
980985
{
@@ -1161,10 +1166,11 @@ class PolymodInterpEx extends Interp
11611166
// #end
11621167
// return result;
11631168
}
1164-
#if hl
1169+
#if (hl && haxe4)
11651170
else if (Std.isOfType(o, Enum))
11661171
{
1167-
try {
1172+
try
1173+
{
11681174
return (o:Enum<Dynamic>).createByName(f);
11691175
}
11701176
catch (e)
@@ -1180,8 +1186,18 @@ class PolymodInterpEx extends Interp
11801186
}
11811187

11821188
// Default behavior
1183-
if (Reflect.hasField(o, f)) {
1189+
if (Reflect.hasField(o, f))
1190+
{
1191+
#if hl
1192+
// On HL, hasField on properties returns true but Reflect.field might return null, this happens mostly
1193+
// when the programmer mistakenly makes the field access (get, null) instead of (get, never)
1194+
// I hate having to use 'getInstanceFields' for this but I can't bother making a cache solely for it
1195+
var r:Null<Dynamic> = Reflect.field(o, f);
1196+
if (r == null && Type.getInstanceFields(Type.getClass(o) ?? return null).contains('get_$f')) r = Reflect.getProperty(o, f);
1197+
return r;
1198+
#else
11841199
return Reflect.field(o, f);
1200+
#end
11851201
} else {
11861202
try {
11871203
return Reflect.getProperty(o, f);

0 commit comments

Comments
 (0)