diff --git a/napi-inl.h b/napi-inl.h index c75ce6c03..f51c4a790 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -3137,12 +3137,11 @@ inline ObjectWrap::ObjectWrap(const Napi::CallbackInfo& callbackInfo) { napi_value wrapper = callbackInfo.This(); napi_status status; napi_ref ref; - T* instance = static_cast(this); - status = napi_wrap(env, wrapper, instance, FinalizeCallback, nullptr, &ref); + status = napi_wrap(env, wrapper, this, FinalizeCallback, nullptr, &ref); NAPI_THROW_IF_FAILED_VOID(env, status); ObjectWrapCleanup::MarkWrapOK(callbackInfo); - Reference* instanceRef = instance; + Reference* instanceRef = this; *instanceRef = Reference(env, ref); } @@ -3722,7 +3721,7 @@ inline napi_value ObjectWrap::ConstructorCallbackWrapper( try { new T(callbackInfo); } catch (const Error& e) { - // re-throw the error after removing the failed wrap. + // Re-throw the error after removing the failed wrap. cleanup.RemoveWrap(callbackInfo); throw e; }