(* TEST * expect *) class virtual child1 parent = object method private parent = parent end class virtual child2 = object(_ : 'self) constraint 'parent = < previous: 'self option; .. > method private virtual parent: 'parent end (* Worked in 4.03 *) let _ = object(self) method previous = None method child = object inherit child1 self inherit child2 end end;; [%%expect{| class virtual child1 : 'a -> object method private parent : 'a end class virtual child2 : object ('a) method private virtual parent : < previous : 'a option; .. > end - : < child : child2; previous : child2 option > = |}] (* Worked in 4.03 *) let _ = object(self) method previous = None method child (_ : unit) = object inherit child1 self inherit child2 end end;; [%%expect{| - : < child : unit -> child2; previous : child2 option > = |}] (* Worked in 4.03 *) let _ = object(self) method previous = None method child () = object inherit child1 self inherit child2 end end;; [%%expect{| - : < child : unit -> child2; previous : child2 option > = |}] (* Didn't work in 4.03, but works in 4.07 *) let _ = object(self) method previous = None method child = let o = object inherit child1 self inherit child2 end in o end;; [%%expect{| - : < child : child2; previous : child2 option > = |}] (* Also didn't work in 4.03 *) type gadt = Not_really_though : gadt let _ = object(self) method previous = None method child Not_really_though = object inherit child1 self inherit child2 end end;; [%%expect{| type gadt = Not_really_though : gadt - : < child : gadt -> child2; previous : child2 option > = |}]