summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2013-10-01 15:14:04 +0000
committerAlain Frisch <alain@frisch.fr>2013-10-01 15:14:04 +0000
commitc9557989360b5c00c14f6951feda47b3be582aa0 (patch)
tree835e3e48449e1a4c7e06fd29a12f0cfc05e7ae65
parent5554eb13e93aef36861b09901a450022733eb2f9 (diff)
downloadocaml-c9557989360b5c00c14f6951feda47b3be582aa0.tar.gz
Keep attributes with module type declarations. Warning on reference to deprecated module type.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14206 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rwxr-xr-xboot/ocamlcbin1491175 -> 1491443 bytes
-rwxr-xr-xboot/ocamldepbin414846 -> 414838 bytes
-rwxr-xr-xboot/ocamllexbin181399 -> 181399 bytes
-rw-r--r--ocamldoc/odoc_ast.ml2
-rw-r--r--ocamldoc/odoc_env.ml6
-rw-r--r--ocamldoc/odoc_sig.ml4
-rw-r--r--typing/env.ml6
-rw-r--r--typing/includemod.ml10
-rw-r--r--typing/mtype.ml18
-rw-r--r--typing/printtyp.ml6
-rw-r--r--typing/subst.ml10
-rw-r--r--typing/typemod.ml37
-rw-r--r--typing/types.ml7
-rw-r--r--typing/types.mli8
-rw-r--r--typing/typetexp.ml9
15 files changed, 66 insertions, 57 deletions
diff --git a/boot/ocamlc b/boot/ocamlc
index ca330237e2..e53566d00f 100755
--- a/boot/ocamlc
+++ b/boot/ocamlc
Binary files differ
diff --git a/boot/ocamldep b/boot/ocamldep
index cad3c8e58b..ccc018c22a 100755
--- a/boot/ocamldep
+++ b/boot/ocamldep
Binary files differ
diff --git a/boot/ocamllex b/boot/ocamllex
index 3777e1e772..7c8b0a5e84 100755
--- a/boot/ocamllex
+++ b/boot/ocamllex
Binary files differ
diff --git a/ocamldoc/odoc_ast.ml b/ocamldoc/odoc_ast.ml
index dd106b4f04..6f0a8d572b 100644
--- a/ocamldoc/odoc_ast.ml
+++ b/ocamldoc/odoc_ast.ml
@@ -955,7 +955,7 @@ module Analyser =
| _ -> false)
| Element_module_type mt ->
(function
- Types.Sig_modtype (ident,Types.Modtype_manifest t) ->
+ Types.Sig_modtype (ident,{Types.mtd_type=Some t}) ->
let n1 = Name.simple mt.mt_name
and n2 = Ident.name ident in
(
diff --git a/ocamldoc/odoc_env.ml b/ocamldoc/odoc_env.ml
index 7a9c86eddb..5fd1f05080 100644
--- a/ocamldoc/odoc_env.ml
+++ b/ocamldoc/odoc_env.ml
@@ -62,10 +62,10 @@ let rec add_signature env root ?rel signat =
{ env2 with env_modules = (rel_name ident, qualify ident) :: env2.env_modules }
| Types.Sig_modtype (ident, modtype_decl) ->
let env2 =
- match modtype_decl with
- Types.Modtype_abstract ->
+ match modtype_decl.Types.mtd_type with
+ None ->
env
- | Types.Modtype_manifest modtype ->
+ | Some modtype ->
match modtype with
(* A VOIR : le cas ou c'est un identificateur, dans ce cas on n'a pas de signature *)
Types.Mty_signature s -> add_signature env (qualify ident) ~rel: (rel_name ident) s
diff --git a/ocamldoc/odoc_sig.ml b/ocamldoc/odoc_sig.ml
index 4ea3521741..6f6eaedf12 100644
--- a/ocamldoc/odoc_sig.ml
+++ b/ocamldoc/odoc_sig.ml
@@ -99,9 +99,9 @@ module Signature_search =
let search_module_type table name =
match Hashtbl.find table (MT name) with
- | (Types.Sig_modtype (_, Types.Modtype_manifest module_type)) ->
+ | (Types.Sig_modtype (_, {Types.mtd_type = Some module_type})) ->
Some module_type
- | (Types.Sig_modtype (_, Types.Modtype_abstract)) ->
+ | (Types.Sig_modtype (_, {Types.mtd_type = None})) ->
None
| _ -> assert false
diff --git a/typing/env.ml b/typing/env.ml
index 7431ed7c39..beee7a17d2 100644
--- a/typing/env.ml
+++ b/typing/env.ml
@@ -465,9 +465,9 @@ let find_type_expansion_opt path env =
| _ -> raise Not_found
let find_modtype_expansion path env =
- match find_modtype path env with
- Modtype_abstract -> raise Not_found
- | Modtype_manifest mty -> mty
+ match (find_modtype path env).mtd_type with
+ | None -> raise Not_found
+ | Some mty -> mty
let find_module path env =
match path with
diff --git a/typing/includemod.ml b/typing/includemod.ml
index 7ea228600e..302890ed28 100644
--- a/typing/includemod.ml
+++ b/typing/includemod.ml
@@ -305,12 +305,12 @@ and modtype_infos env cxt subst id info1 info2 =
let info2 = Subst.modtype_declaration subst info2 in
let cxt' = Modtype id :: cxt in
try
- match (info1, info2) with
- (Modtype_abstract, Modtype_abstract) -> ()
- | (Modtype_manifest mty1, Modtype_abstract) -> ()
- | (Modtype_manifest mty1, Modtype_manifest mty2) ->
+ match (info1.mtd_type, info2.mtd_type) with
+ (None, None) -> ()
+ | (Some mty1, None) -> ()
+ | (Some mty1, Some mty2) ->
check_modtype_equiv env cxt' mty1 mty2
- | (Modtype_abstract, Modtype_manifest mty2) ->
+ | (None, Some mty2) ->
check_modtype_equiv env cxt' (Mty_ident(Pident id)) mty2
with Error reasons ->
raise(Error((cxt, env, Modtype_infos(id, info1, info2)) :: reasons))
diff --git a/typing/mtype.ml b/typing/mtype.ml
index 37e66bddfd..53850d962a 100644
--- a/typing/mtype.ml
+++ b/typing/mtype.ml
@@ -68,11 +68,12 @@ and strengthen_sig env sg p =
(* Need to add the module in case it defines manifest module types *)
| Sig_modtype(id, decl) :: rem ->
let newdecl =
- match decl with
- Modtype_abstract ->
- Modtype_manifest(Mty_ident(Pdot(p, Ident.name id, nopos)))
- | Modtype_manifest _ ->
- decl in
+ match decl.mtd_type with
+ None ->
+ {decl with mtd_type = Some(Mty_ident(Pdot(p, Ident.name id, nopos)))}
+ | Some _ ->
+ decl
+ in
Sig_modtype(id, newdecl) ::
strengthen_sig (Env.add_modtype id decl env) rem p
(* Need to add the module type in case it is manifest *)
@@ -134,7 +135,7 @@ let nondep_supertype env mid mty =
Sig_modtype(id, nondep_modtype_decl env d) :: rem'
with Not_found ->
match va with
- Co -> Sig_modtype(id, Modtype_abstract) :: rem'
+ Co -> Sig_modtype(id, {mtd_type=None; mtd_attributes=[]}) :: rem'
| _ -> raise Not_found
end
| Sig_class(id, d, rs) ->
@@ -144,9 +145,8 @@ let nondep_supertype env mid mty =
Sig_class_type(id, Ctype.nondep_cltype_declaration env mid d, rs)
:: rem'
- and nondep_modtype_decl env = function
- Modtype_abstract -> Modtype_abstract
- | Modtype_manifest mty -> Modtype_manifest(nondep_mty env Strict mty)
+ and nondep_modtype_decl env mtd =
+ {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type}
in
nondep_mty env Co mty
diff --git a/typing/printtyp.ml b/typing/printtyp.ml
index a3f42d63ce..1f7e501984 100644
--- a/typing/printtyp.ml
+++ b/typing/printtyp.ml
@@ -1157,9 +1157,9 @@ and tree_of_signature_rec env' = function
and tree_of_modtype_declaration id decl =
let mty =
- match decl with
- | Modtype_abstract -> Omty_abstract
- | Modtype_manifest mty -> tree_of_modtype mty
+ match decl.mtd_type with
+ | None -> Omty_abstract
+ | Some mty -> tree_of_modtype mty
in
Osig_modtype (Ident.name id, mty)
diff --git a/typing/subst.ml b/typing/subst.ml
index 4fda72ac48..6acf9323dd 100644
--- a/typing/subst.ml
+++ b/typing/subst.ml
@@ -355,16 +355,18 @@ and signature_component s comp newid =
| Sig_class_type(id, d, rs) ->
Sig_class_type(newid, cltype_declaration s d, rs)
-and modtype_declaration s = function
- Modtype_abstract -> Modtype_abstract
- | Modtype_manifest mty -> Modtype_manifest(modtype s mty)
-
and module_declaration s decl =
{
md_type = modtype s decl.md_type;
md_attributes = attrs s decl.md_attributes;
}
+and modtype_declaration s decl =
+ {
+ mtd_type = may_map (modtype s) decl.mtd_type;
+ mtd_attributes = attrs s decl.mtd_attributes;
+ }
+
(* For every binding k |-> d of m1, add k |-> f d to m2
and return resulting merged map. *)
diff --git a/typing/typemod.ml b/typing/typemod.ml
index 9f7195acbf..c97fab2e8c 100644
--- a/typing/typemod.ml
+++ b/typing/typemod.ml
@@ -350,7 +350,7 @@ and approx_sig env ssg =
map_rec (fun rs (id, md) -> Sig_module(id, md, rs)) decls
(approx_sig newenv srem)
| Psig_modtype d ->
- let info = approx_modtype_info env d.pmtd_type in
+ let info = approx_modtype_info env d in
let (id, newenv) = Env.enter_modtype d.pmtd_name.txt info env in
Sig_modtype(id, info) :: approx_sig newenv srem
| Psig_open (ovf, lid, _attrs) ->
@@ -376,11 +376,10 @@ and approx_sig env ssg =
approx_sig env srem
and approx_modtype_info env sinfo =
- match sinfo with
- None ->
- Modtype_abstract
- | Some smty ->
- Modtype_manifest(approx_modtype env smty)
+ {
+ mtd_type = may_map (approx_modtype env) sinfo.pmtd_type;
+ mtd_attributes = sinfo.pmtd_attributes;
+ }
(* Additional validity checks on type definitions arising from
recursive modules *)
@@ -652,25 +651,23 @@ and transl_signature env sg =
and transl_modtype_decl modtype_names env loc
{pmtd_name; pmtd_type; pmtd_attributes} =
check "module type" loc modtype_names pmtd_name.txt;
- let (tinfo, info) = transl_modtype_info env pmtd_type in
- let (id, newenv) = Env.enter_modtype pmtd_name.txt info env in
+ let tmty = Misc.may_map (transl_modtype env) pmtd_type in
+ let decl =
+ {
+ mtd_type=may_map (fun t -> t.mty_type) tmty;
+ mtd_attributes=pmtd_attributes;
+ }
+ in
+ let (id, newenv) = Env.enter_modtype pmtd_name.txt decl env in
let mtd =
{
mtd_id=id;
mtd_name=pmtd_name;
- mtd_type=tinfo;
+ mtd_type=tmty;
mtd_attributes=pmtd_attributes;
}
in
- newenv, mtd, Sig_modtype(id, info)
-
-and transl_modtype_info env sinfo =
- match sinfo with
- None ->
- None, Modtype_abstract
- | Some smty ->
- let tmty = transl_modtype env smty in
- Some tmty, Modtype_manifest tmty.mty_type
+ newenv, mtd, Sig_modtype(id, decl)
and transl_recmodule_modtypes loc env sdecls =
let make_env curr =
@@ -907,8 +904,8 @@ let rec package_constraints env loc mty constrs =
Mty_signature sg'
let modtype_of_package env loc p nl tl =
- try match Env.find_modtype p env with
- | Modtype_manifest mty when nl <> [] ->
+ try match (Env.find_modtype p env).mtd_type with
+ | Some mty when nl <> [] ->
package_constraints env loc mty
(List.combine (List.map Longident.flatten nl) tl)
| _ ->
diff --git a/typing/types.ml b/typing/types.ml
index ae2df93934..20fa3836ea 100644
--- a/typing/types.ml
+++ b/typing/types.ml
@@ -282,9 +282,12 @@ and module_declaration =
md_type: module_type;
md_attributes: Parsetree.attributes;
}
+
and modtype_declaration =
- Modtype_abstract
- | Modtype_manifest of module_type
+ {
+ mtd_type: module_type option; (* Nonte: abstract *)
+ mtd_attributes: Parsetree.attributes;
+ }
and rec_status =
Trec_not (* not recursive *)
diff --git a/typing/types.mli b/typing/types.mli
index a1b2b1c383..62fad9653f 100644
--- a/typing/types.mli
+++ b/typing/types.mli
@@ -260,7 +260,7 @@ and signature_item =
| Sig_type of Ident.t * type_declaration * rec_status
| Sig_exception of Ident.t * exception_declaration
| Sig_module of Ident.t * module_declaration * rec_status
- | Sig_modtype of Ident.t * modtype_declaration (* todo: attributes *)
+ | Sig_modtype of Ident.t * modtype_declaration
| Sig_class of Ident.t * class_declaration * rec_status
| Sig_class_type of Ident.t * class_type_declaration * rec_status
@@ -271,8 +271,10 @@ and module_declaration =
}
and modtype_declaration =
- Modtype_abstract
- | Modtype_manifest of module_type
+ {
+ mtd_type: module_type option; (* Nonte: abstract *)
+ mtd_attributes: Parsetree.attributes;
+ }
and rec_status =
Trec_not (* not recursive *)
diff --git a/typing/typetexp.ml b/typing/typetexp.ml
index 560bcec735..79aefb1e6c 100644
--- a/typing/typetexp.ml
+++ b/typing/typetexp.ml
@@ -142,8 +142,13 @@ let find_module env loc lid =
check_deprecated loc decl.md_attributes (Path.name path);
r
-let find_modtype =
- find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid)
+let find_modtype env loc lid =
+ let (path, decl) as r =
+ find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid)
+ env loc lid
+ in
+ check_deprecated loc decl.mtd_attributes (Path.name path);
+ r
let find_class_type env loc lid =
let (path, decl) as r =