Version française
Home     About     Download     Resources     Contact us    
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
end

class b = object 
  inherit a
  method h = 1
end

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

I got an error for the last statement.

I am reading the work on extension problem found at 
  http://pauillac.inria.fr/~remy/work/expr/
then, 
I am curious to know how ocaml compiler judges subtyping relation 
involving self types.

Regards,
Keiko NAKATA.