Track the object instead and don’t change the type of the pointer to scope.
I guess this is flow typing too, but it is less intrusive to say that the object is either of type «scope» or type «heap» and that regular pointers can hold both than to change the concrete pointer type.
Specified concrete types should not change.