Dear list,

I'm not sure why the following class definition is typed the way it is:

        OCaml version 4.02.1

# 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. This bites me when I try to specialize the type :

# type 'a t = (< m : int ; .. > as 'a) c;;
Error: This type < m : int; .. > should be an instance of type 'a c as 'a
Types for method m are incompatible


Instead of the type with polymorphic methods, I would have expected the following type:

# class type ['a] c = object ('a) constraint 'a = < m : 'b; .. > method m : 'b end;;
class type ['a] c = object ('a) constraint 'a = < m : 'b; .. > method m : 'b end

And then have no problems doing what I wanted:

# type 'a t = (< m : int ; .. > as 'a) c;;
type 'a t = 'a constraint 'a = < m : int >


What did I get wrong?

Cheers,
  Philippe.