Thanks Leo! This default behaviour is a bit surprising since usually, methods are not typed as polymorphic unless stated explicitely. Here, if I wanted the method m to be more polymorphic I could have written this: # class type ['a] c = object ('a) method m : 'b. 'b end;; class type ['a] c = object ('a) constraint 'a = < m : 'b. 'b; .. > method m : 'b end This was an easy way to say that the polymorphism of m was not captured by 'a. I don't want to abuse your time, but if you have a tiny example illustrating when this automatic promotion is indeed useful, I'd be curious to see it. In any case, many thanks for the fix, which I'll use right away. cheers, ph. 2014-10-30 16:19 GMT+01:00 Leo White : > > # class type ['a] c = object ('a) method m : 'b end;; > > class type ['a] c = object ('a) constraint 'a = < m : 'b. 'b; .. > > method m : 'b end > > > > In particular I don't understand why the method m gets a polymorphic > > type. > > To allow shorter type annotations for class types, OCaml tries to > automatically turn methods with polymorphic types into polymorphic > methods. In this case it is being a bit over eager and making your > method polymorphic even though it doesn't need to. > > You can fix this by making it more obvious that your method's > polymorphism is contained within the class parameter 'a. You can do this > by writing in the constraint by hand: > > class type ['a] c = object ('a) > constraint 'a = < m : 'b; ..> > method m : 'b > end > > Which now allows your type definition to work: > > # type 'a t = (< m : int ; .. > as 'a) c;; > type 'a t = 'a c constraint 'a = < m : int > > > Regards, > > Leo >