Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lolcathost% ocaml
- OCaml version 4.02.3
- # class foo = object (_ : 'a) method test (_ : 'a) = () end;;
- class foo : object ('a) method test : 'a -> unit end
- # class bar = object inherit foo method other = () end;;
- class bar : object ('a) method other : unit method test : 'a -> unit end
- # let f = new foo;;
- val f : foo = <obj>
- # let b = new bar;;
- val b : bar = <obj>
- # f#test f;;
- - : unit = ()
- # b#test b;;
- - : unit = ()
- # f#test b;;
- Characters 7-8:
- f#test b;;
- ^
- Error: This expression has type bar but an expression was expected of type
- foo
- The second object type has no method other
- # b#test f;;
- Characters 7-8:
- b#test f;;
- ^
- Error: This expression has type foo but an expression was expected of type
- bar
- The first object type has no method other
- #
Advertisement
Add Comment
Please, Sign In to add comment