I am not sure what the result of your test() should be and for what you will
use that result.
You can use type(x) to get the static base type of an object and name from
typetraits module to get the typename: Following code works, but I don't know
if it can help you:
type
A = ref object of RootObj
B = ref object of A
i: int
var b = new B
var s = newSeq[A]()
s.add(new A)
s.add(new B)
echo s[0] of A
echo s[0] of B
echo s[1] of A
echo s[1] of B
var x: type(s[1])
assert x is A # it is not B!
import typetraits
echo type(s[1]).name
echo type(x).name
Run
$ ./t
true
false
true
true
A
A
Run