Commits

camlspotter committed fd92f59 Merge

update

  • Participants
  • Parent commits f9bd203, d7f1e62
  • Branches custom

Comments (0)

Files changed (3)

boot/ocamlc

Binary file modified.

ocamlspot/othertests/overload.ml

 module M = struct
   module N = struct
+    type t = int
     let print = print_int
     let (+) = (+)
     let one = 1
   end
   module O = struct
+    type t = float
     let print = print_float
     let (+) = (+.)
     let one = 1.0
   { newenv with summary = Env_open(env.summary, root) }
 
 let mtype_scrape = ref (fun _ -> assert false)
-let rec open_signature_overload loc root sg env =
+let rec open_signature_overload ?(first_level=true) loc orig_root root sg env =
   (* Format.eprintf "%a %s@." format_longident lid (Path.unique_name p); *)
   (* jfuruse Format.eprintf "open %s@." (Path.unique_name root); *)
   add_opened_module loc root; (* No warning for recursive open *)
       (fun env item p ->
         match item with
           Tsig_value(id, decl) ->
-            let e1 = store_value ~opened:root (Ident.hide id) p
+            let e1 = store_value ~opened:orig_root (Ident.hide id) p
                         ~overloaded:true 
                         (Subst.value_description sub decl) env
             in store_annot (Ident.hide id) p (Annot.Iref_external) e1
-        | Tsig_type(id, decl, _) ->
-            store_type ~opened:root (Ident.hide id) p
+        | Tsig_type(id, decl, _) when first_level ->
+            store_type ~opened:orig_root (Ident.hide id) p
                        (Subst.type_declaration sub decl) env
-        | Tsig_exception(id, decl) ->
-            store_exception ~opened:root (Ident.hide id) p
+        | Tsig_exception(id, decl) when first_level ->
+            store_exception ~opened:orig_root (Ident.hide id) p
                             (Subst.exception_declaration sub decl) env
         | Tsig_module(id, mty, _) ->
+            let root' = p in
             begin match !mtype_scrape env mty with
               | Tmty_signature sg' -> 
-                  let env' = store_module ~opened:root (Ident.hide id) p (Subst.modtype sub mty) env in
-                  open_signature_overload Location.none root sg' env'
+                  let env' = if first_level then store_module ~opened:orig_root (Ident.hide id) p (Subst.modtype sub mty) env else env in
+                  open_signature_overload ~first_level:false Location.none orig_root root' sg' env'
               | _ -> 
-                  store_module ~opened:root (Ident.hide id) p (Subst.modtype sub mty) env
+                  if first_level then 
+                    store_module ~opened:orig_root (Ident.hide id) p (Subst.modtype sub mty) env
+                  else env
             end
-        | Tsig_modtype(id, decl) ->
-            store_modtype ~opened:root (Ident.hide id) p
+        | Tsig_modtype(id, decl) when first_level ->
+            store_modtype ~opened:orig_root (Ident.hide id) p
                           (Subst.modtype_declaration sub decl) env
-        | Tsig_class(id, decl, _) ->
-            store_class ~opened:root (Ident.hide id) p
+        | Tsig_class(id, decl, _) when first_level ->
+            store_class ~opened:orig_root (Ident.hide id) p
                         (Subst.class_declaration sub decl) env
-        | Tsig_cltype(id, decl, _) ->
-            store_cltype ~opened:root (Ident.hide id) p
-                         (Subst.cltype_declaration sub decl) env)
+        | Tsig_cltype(id, decl, _) when first_level ->
+            store_cltype ~opened:orig_root (Ident.hide id) p
+                         (Subst.cltype_declaration sub decl) env
+        | _ -> env)
       env sg pl in
   { newenv with summary = Env_open(env.summary, root) }
 
+let open_signature_overload loc root = open_signature_overload ~first_level:true loc root root
+
 (* Open a signature from a file *)
 
 let open_pers_signature name env =