2 ===================================================================
3 RCS file: /net/yquem/devel/caml/repository/csl/typing/ctype.ml,v
4 retrieving revision 1.201
5 diff -u -r1.201 ctype.ml
6 --- typing/ctype.ml 5 Apr 2006 02:28:13 -0000 1.201
7 +++ typing/ctype.ml 17 May 2006 23:48:22 -0000
9 unmark_class_signature sign;
12 +(* Variant for checking principality *)
14 +let rec free_nodes_rec ty =
16 + if ty.level >= lowest_level then begin
17 + if ty.level <= !current_level then raise Exit;
18 + ty.level <- pivot_level - ty.level;
19 + begin match ty.desc with
22 + | Tobject (ty, _) ->
24 + | Tfield (_, _, ty1, ty2) ->
25 + free_nodes_rec ty1; free_nodes_rec ty2
27 + let row = row_repr row in
28 + iter_row free_nodes_rec {row with row_bound = []};
29 + if not (static_row row) then free_nodes_rec row.row_more
31 + iter_type_expr free_nodes_rec ty
35 +let has_free_nodes ty =
36 + try free_nodes_rec ty; false with Exit -> true
38 (**********************)
39 (* Type duplication *)
40 Index: typing/ctype.mli
41 ===================================================================
42 RCS file: /net/yquem/devel/caml/repository/csl/typing/ctype.mli,v
43 retrieving revision 1.54
44 diff -u -r1.54 ctype.mli
45 --- typing/ctype.mli 5 Apr 2006 02:28:13 -0000 1.54
46 +++ typing/ctype.mli 17 May 2006 23:48:22 -0000
49 type_expr list -> class_signature -> closed_class_failure option
50 (* Check whether all type variables are bound *)
51 +val has_free_nodes: type_expr -> bool
52 + (* Check whether there are free type variables, or nodes with
53 + level lower or equal to !current_level *)
55 val unalias: type_expr -> type_expr
56 val signature_of_class_type: class_type -> class_signature
57 Index: typing/typecore.ml
58 ===================================================================
59 RCS file: /net/yquem/devel/caml/repository/csl/typing/typecore.ml,v
60 retrieving revision 1.181
61 diff -u -r1.181 typecore.ml
62 --- typing/typecore.ml 16 Apr 2006 23:28:22 -0000 1.181
63 +++ typing/typecore.ml 17 May 2006 23:48:22 -0000
64 @@ -1183,12 +1183,29 @@
66 Typetexp.transl_simple_type_delayed env sty'
68 + if !Clflags.principal then begin_def ();
69 let arg = type_exp env sarg in
71 + if !Clflags.principal then begin
73 + let b = has_free_nodes arg.exp_type in
74 + Ctype.unify env arg.exp_type (newvar ());
77 + free_variables arg.exp_type <> []
79 begin match arg.exp_desc, !self_coercion, (repr ty').desc with
80 Texp_ident(_, {val_kind=Val_self _}), (path,r) :: _,
81 Tconstr(path',_,_) when Path.same path path' ->
82 r := sexp.pexp_loc :: !r;
84 + | _ when not has_fv ->
86 + let force' = subtype env arg.exp_type ty' in
88 + with Subtype (tr1, tr2) ->
89 + raise(Error(sexp.pexp_loc, Not_subtype(tr1, tr2)))
92 let ty, b = enlarge_type env ty' in