Fix inlined member calls, on user objects on 64-bit VBA
In 64-bit VBA hosts, inlined member calls on user objects don't work like on 32-bit VBA hosts.
Given a UserClass with a getter/setter and a Class_Terminate handler (even it is empty).
And in a TestModule a factory procedure returning an instance of this class and also setting the setter.
When I now use this procedure and inline check the value of the getter like in the following sample, it results in a different behaviour compared to 32-bit VBA:
If CreateUserClass(True).TheValue Then
Please take a look in the attached text file for a complete sample.
Mathieu Guindon commented
Until this is fixed, you can ensure consistent behavior between different host bitness by avoiding member calls against an object whose reference isn't held in the current scope.
IOW declare a local object variable, assign it to the factory method's result, *then* make the member calls against the local variable - chaining member calls directly against the factory method (i.e. any method that returns an object defined by a user class) can cause this undefined behavior; the Terminate handler is a red herring, the problem is that the object is out of scope and the reference count is off (in x64) because of this.
Rubberduck will implement an inspection to flag instances of this: https://github.com/rubberduck-vba/Rubberduck/issues/4442