romainfrancois commented on a change in pull request #8246:
URL: https://github.com/apache/arrow/pull/8246#discussion_r494095853



##########
File path: r/src/arrow_cpp11.h
##########
@@ -157,8 +157,15 @@ struct ns {
 
 template <typename Pointer>
 Pointer r6_to_pointer(SEXP self) {
-  return reinterpret_cast<Pointer>(
-      R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp)));
+  void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
+  if (p == nullptr) {
+    SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
+    std::string first_class(Rf_isNull(klass) ? "ArrowObject"
+                                             : CHAR(STRING_ELT(klass, 0)));

Review comment:
       I'll refine about the NULL case, but the class we do want is the first 
one: 
   
   ``` r
   library(arrow, warn.conflicts = FALSE)
   
   a <- Array$create(1:10)
   class(a)
   #> [1] "Array"       "ArrowObject" "R6"
   ```
   
   <sup>Created on 2020-09-24 by the [reprex 
package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to