From 26f7cce1e141fad15d132fba9951f68cdc86f9ba Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Wed, 19 Feb 2025 12:49:25 +0500 Subject: [PATCH] fix: inner type should net be set when companion object is defined as function --- test-app/runtime/src/main/cpp/MetadataNode.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test-app/runtime/src/main/cpp/MetadataNode.cpp b/test-app/runtime/src/main/cpp/MetadataNode.cpp index 612f25b37..7d3335fb2 100644 --- a/test-app/runtime/src/main/cpp/MetadataNode.cpp +++ b/test-app/runtime/src/main/cpp/MetadataNode.cpp @@ -859,11 +859,15 @@ void MetadataNode::SetInnerTypes(v8::Isolate* isolate, Local& ctorFunc auto context = isolate->GetCurrentContext(); const auto &children = *treeNode->children; for (auto curChild: children) { - ctorFunction->SetAccessor( - context, - v8::String::NewFromUtf8(isolate, curChild->name.c_str()).ToLocalChecked(), - InnerTypeAccessorGetterCallback, nullptr, v8::External::New(isolate, curChild) - ); + bool hasOwnProperty = ctorFunction->HasOwnProperty(context, ArgConverter::ConvertToV8String(isolate, curChild->name)).ToChecked(); + // Child is defined as a function already when the inner type is a companion object + if (!hasOwnProperty) { + ctorFunction->SetAccessor( + context, + v8::String::NewFromUtf8(isolate, curChild->name.c_str()).ToLocalChecked(), + InnerTypeAccessorGetterCallback, nullptr, v8::External::New(isolate, curChild) + ); + } } } }