1. HongboZhang
  2. ocaml

Commits

garrigue  committed bd82649

applied (improved) patch of PR#5654

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12613f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

  • Participants
  • Parent commits bf81e15
  • Branches master

Comments (0)

Files changed (2)

File bytecomp/translclass.ml

View file
  • Ignore whitespace
                     (vals, meths_super cla str.cstr_meths meths)
                     inh_init cl_init msubst top cl in
                 (inh_init, cl_init, [], values)
-            | Tcf_val (name, _, _, id, Tcfk_concrete exp, over) ->
+            | Tcf_val (name, _, _, id, exp, over) ->
                 let values = if over then values else (name, id) :: values in
                 (inh_init, cl_init, methods, values)
-            | Tcf_val (_, _, _, _, Tcfk_virtual _, _)
             | Tcf_meth (_, _, _, Tcfk_virtual _, _)
             | Tcf_constr _
               ->

File typing/typeclass.ml

View file
  • Ignore whitespace
   end;
   (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 =
+  let mkpat d = { ppat_desc = d; ppat_loc = self_loc } in
+  let mkid s = mkloc s self_loc in
   { pexp_desc =
       Pexp_function ("", None,
-                     [mkpat (Ppat_alias (mkpat(Ppat_var (mknoloc "self-*")),
-                                         mknoloc ("self-" ^ cl_num))),
+                     [mkpat (Ppat_alias (mkpat (Ppat_var (mkid "self-*")),
+                                         mkid ("self-" ^ cl_num))),
                       expr]);
     pexp_loc = expr.pexp_loc }
 
 
 (*******************************)
 
-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
       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
 
         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
   (* Environment for substructures *)
   let par_env = met_env in
 
+  (* Location of self. Used for locations of self arguments *)
+  let self_loc = {spat.ppat_loc with Location.loc_ghost = true} in
+
   (* Self type, with a dummy method preventing it from being closed/escaped. *)
   let self_type = Ctype.newvar () in
   Ctype.unify val_env
 
   (* 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