Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make aliases absent in module type of #1750

Merged
merged 3 commits into from May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified boot/ocamlc
Binary file not shown.
Binary file modified boot/ocamllex
Binary file not shown.
12 changes: 12 additions & 0 deletions testsuite/tests/typing-modules/aliases.ml
Expand Up @@ -783,3 +783,15 @@ module M : sig type t end
module type S = sig module N = M val x : N.t end
module type T = sig val x : M.t end
|}];;


module X = struct module N = struct end end
module Y : sig
module type S = sig module N = X.N end
end = struct
module type S = module type of struct include X end
end;;
[%%expect{|
module X : sig module N : sig end end
module Y : sig module type S = sig module N = X.N end end
|}];;
24 changes: 23 additions & 1 deletion typing/mtype.ml
Expand Up @@ -107,6 +107,28 @@ and strengthen_decl ~aliasable env md p =

let () = Env.strengthen := strengthen

let rec make_aliases_absent mty =
match mty with
| Mty_alias(_, p) ->
Mty_alias(Mta_absent, p)
| Mty_signature sg ->
Mty_signature(make_aliases_absent_sig sg)
| Mty_functor(param, arg, res) ->
Mty_functor(param, arg, make_aliases_absent res)
| mty ->
mty

and make_aliases_absent_sig sg =
match sg with
[] -> []
| Sig_module(id, md, rs) :: rem ->
let str =
{ md with md_type = make_aliases_absent md.md_type }
in
Sig_module(id, str, rs) :: make_aliases_absent_sig rem
| sigelt :: rem ->
sigelt :: make_aliases_absent_sig rem

let scrape_for_type_of env mty =
let rec loop env path mty =
match mty, path with
Expand All @@ -120,7 +142,7 @@ let scrape_for_type_of env mty =
strengthen ~aliasable:false env mty path
| _ -> mty
in
loop env None mty
make_aliases_absent (loop env None mty)

(* In nondep_supertype, env is only used for the type it assigns to id.
Hence there is no need to keep env up-to-date by adding the bindings
Expand Down