Skip to content

Commit e293636

Browse files
authored
fix: inner type should net be set when companion object is defined as function (#1831)
1 parent 14ff14c commit e293636

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test-app/runtime/src/main/cpp/MetadataNode.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,15 @@ void MetadataNode::SetInnerTypes(v8::Isolate* isolate, Local<Function>& ctorFunc
859859
auto context = isolate->GetCurrentContext();
860860
const auto &children = *treeNode->children;
861861
for (auto curChild: children) {
862-
ctorFunction->SetAccessor(
863-
context,
864-
v8::String::NewFromUtf8(isolate, curChild->name.c_str()).ToLocalChecked(),
865-
InnerTypeAccessorGetterCallback, nullptr, v8::External::New(isolate, curChild)
866-
);
862+
bool hasOwnProperty = ctorFunction->HasOwnProperty(context, ArgConverter::ConvertToV8String(isolate, curChild->name)).ToChecked();
863+
// Child is defined as a function already when the inner type is a companion object
864+
if (!hasOwnProperty) {
865+
ctorFunction->SetAccessor(
866+
context,
867+
v8::String::NewFromUtf8(isolate, curChild->name.c_str()).ToLocalChecked(),
868+
InnerTypeAccessorGetterCallback, nullptr, v8::External::New(isolate, curChild)
869+
);
870+
}
867871
}
868872
}
869873
}

0 commit comments

Comments
 (0)