import typeinfo
type CustomAny* = object
value: pointer
rawType: pointer
proc customToAny*[T](x: var T): CustomAny {.inline.} =
result = cast[CustomAny](toAny(x))
proc compareRuntimeTypes[A, B](a: var A, b: var B): bool =
result = customToAny(a).rawType == customToAny(b).rawType
type
Parent = ref object {.inheritable.}
Derived = ref object of Parent
var a: Parent = Parent()
var b: Parent = Derived()
echo "a == b? " & $(compareRuntimeTypes(a, b)) # ==> true, expected false