| Attached Files | diff [^] (2,200 bytes) 2012-06-19 10:20 [Show Content] [Hide Content]diff -r 86adfe1982ef -r c50d9ff68898 typing/typeclass.ml
--- a/typing/typeclass.ml Fri Jun 15 23:13:01 2012 +0900
+++ b/typing/typeclass.ml Mon Jun 18 03:12:40 2012 +0900
@@ -344,11 +344,11 @@
(cty, cty')
let mkpat d = { ppat_desc = d; ppat_loc = Location.none }
-let make_method cl_num expr =
+let make_method self_loc cl_num expr =
{ pexp_desc =
Pexp_function ("", None,
[mkpat (Ppat_alias (mkpat(Ppat_var (mknoloc "self-*")),
- mknoloc ("self-" ^ cl_num))),
+ mkloc ("self-" ^ cl_num) self_loc)),
expr]);
pexp_loc = expr.pexp_loc }
@@ -492,7 +492,7 @@
(*******************************)
-let rec class_field cl_num self_type meths vars
+let rec class_field self_loc cl_num self_type meths vars
(val_env, met_env, par_env, fields, concr_meths, warn_vals, inher)
cf =
let loc = cf.pcf_loc in
@@ -630,7 +630,7 @@
with Ctype.Unify trace ->
raise(Error(loc, Field_type_mismatch ("method", lab.txt, trace)))
end;
- let meth_expr = make_method cl_num expr in
+ let meth_expr = make_method self_loc cl_num expr in
(* backup variables for Pexp_override *)
let vars_local = !vars in
@@ -657,7 +657,7 @@
concr_meths, warn_vals, inher)
| Pcf_init expr ->
- let expr = make_method cl_num expr in
+ let expr = make_method self_loc cl_num expr in
let vars_local = !vars in
let field =
lazy begin
@@ -678,6 +678,9 @@
(* Environment for substructures *)
let par_env = met_env in
+ (* Location of self. Used for locations of self arguments *)
+ let self_loc = spat.ppat_loc in
+
(* Self type, with a dummy method preventing it from being closed/escaped. *)
let self_type = Ctype.newvar () in
Ctype.unify val_env
@@ -718,7 +721,7 @@
(* Typing of class fields *)
let (_, _, _, fields, concr_meths, _, inher) =
- List.fold_left (class_field cl_num self_type meths vars)
+ List.fold_left (class_field self_loc cl_num self_type meths vars)
(val_env, meth_env, par_env, [], Concr.empty, Concr.empty, [])
str
in
|