C++ interop: is unavailable ... may return an interior pointer

Working on wrapping some C++ code using the new Swift interop, trying to call one of the C++ methods it says it doesn't exists even though it does. XCode shows these notes:

  • C++ method asBare that returns a value of type ObjectPtr<A> is unavaliable
  • C++ method asBare may return an interior pointer

The method returns a heap-allocated object so I'm not sure what is confusing the compiler here to refuse to make it available.

The compiler doesn't know that the method is returning a heap-allocated object, so it assumes it might be returning a reference into the self object, as described here Swift.org - Mixing Swift and C++.
You might want to mark the ObjectPtr type as self contained (Swift.org - Mixing Swift and C++), or the method as returning an independent value (Swift.org - Mixing Swift and C++).