Skip to content

Commit 9cea226

Browse files
committed
fix: correct behavior when using method object as variable value across different structures
Resolved issues that occurred when assigning a method from one struct as a variable value in a different struct, ensuring proper method binding and execution.
1 parent 9a31aa4 commit 9cea226

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

argon/vm/datatype/arobject.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,13 @@ ArObject *argon::vm::datatype::AttributeLoadMethod(const ArObject *object, ArObj
307307
if ((aload = AttributeLoad(object, key, false)) == nullptr)
308308
return nullptr;
309309

310-
if (AR_TYPEOF(aload, type_function_) && ((Function *) aload)->IsMethod())
310+
const auto *func = (Function *) aload;
311+
const auto *base = (TypeInfo *) object;
312+
313+
if(AR_GET_TYPE(base) != type_type_)
314+
base = AR_GET_TYPE(base);
315+
316+
if (AR_TYPEOF(func, type_function_) && func->IsMethod() && TraitIsImplemented(base, func->base))
311317
*is_method = true;
312318

313319
return aload;

0 commit comments

Comments
 (0)