I couldn't find out if this was possible, and just used a (rather ugly) workaround.
Assume we've got a class structure as below:
(defclass a () ())
(defclass b (a) ())
and the method:
(defmethod print-object ((a1 a) stream)
(format stream "instance of A "))
now, I want to call print for 'a then print for 'b, assuming a "type-cast" function exists:
(defmethod print-object ((b1 b) stream)
(prin1 (type-cast b1 'a) stream)
(format stream "instance of B "))
My workaround is to create an object of type a within print-object of b, then call prin1
(defmethod print-object ((b1 b) stream)
(let ((a1 (make-instance 'a)))
(prin1 a1 stream))
(format stream "instance of B "))
I tried coerce and ended up with infinite loop. I just realized I can try using find-method and call-method (would it work?). Or should I try a solution with :around?