Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
class subtyping
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: nakata keiko <keiko@k...>
Subject: class subtyping
I have a question about subtyping between classes.

Why an instance of class a can not coerced into type b?

class a = object (self : 'a)
  method f (x : 'a) = x#g
  method g = 0

class b = object 
  inherit a
  method h = 1

let x = ((new b) :> a) 

I got an error for the last statement.

I am reading the work on extension problem found at
I am curious to know how ocaml compiler judges subtyping relation 
involving self types.