fix method call reflection
Some checks failed
CI / test-core (14, ubuntu-latest, 3.x, nodejs) (push) Failing after 1m49s
CI / test-core (14, ubuntu-latest, 3.x, py) (push) Failing after 2m14s
CI / test-core (14, ubuntu-latest, 3.x, cpp) (push) Failing after 3m1s
CI / test-core (14, ubuntu-latest, 3.x, interp) (push) Failing after 2m41s
CI / test-core (14, ubuntu-latest, 3.x, js) (push) Failing after 2m21s

This commit is contained in:
2025-09-16 08:29:31 -05:00
parent b441537087
commit 2c22889896

View File

@@ -60,6 +60,8 @@
(evalCC exp.def cc)
(throw "Couldn't read valid expression from $s")))
([:ReaderExpDef def]
// In case it needs to be transformed, pass this
(localVar &mut exp (object pos null def def))
(case def
// Special form call
((when (specialForms.exists form) (CallExp (object def (Symbol form)) args))
@@ -72,6 +74,7 @@
(cc (Reflect.callMethod null f values)))))
// Method/function call
((CallExp callable args)
(transformToFieldExp callable)
(evalCC callable ->f
(_evalAllCC args ->values
(case callable
@@ -100,16 +103,9 @@
(cc f)
(return)))
// Check for field access
(let [idx (ident.indexOf ".")]
(unless (= -1 idx)
(let [parts (ident.split ".")
&mut exp (object pos null def (Symbol (first parts)))]
(doFor part (parts.slice 1)
(let [safe (StringTools.startsWith part "?")]
(when safe (set part (part.substr 1)))
(set exp (object pos null def (FieldExp part exp safe)))))
(evalCC exp cc)
(return))))
(when (transformToFieldExp exp)
(evalCC exp cc)
(return))
// Check for ident aliases
(when (identAliases.exists ident)
(evalCC (dictGet identAliases ident) cc)
@@ -131,4 +127,21 @@
(outputs.push v)
(_evalAllCC inputs cc outputs)
})
(cc outputs)))
(cc outputs)))
// Check if an identifier has field access in it, return true if transform it to FieldExp
(method transformToFieldExp [:ReaderExp exp]
(case exp.def
((Symbol ident)
(let [idx (ident.indexOf ".")]
(unless (= -1 idx)
(let [parts (ident.split ".")
&mut newExp (object pos null def (Symbol (first parts)))]
(doFor part (parts.slice 1)
(let [safe (StringTools.startsWith part "?")]
(when safe (set part (part.substr 1)))
(set newExp (object pos null def (FieldExp part newExp safe)))))
(set exp.def newExp.def)
(return true)))))
(never otherwise))
false)