Skip to content

Commit 735e246

Browse files
author
Roman Leshchinskiy
committed
Add separate type for clarity
1 parent ac84b3e commit 735e246

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ocaml/typing/mtype.ml

+8-5
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,12 @@ let collect_arg_paths mty =
717717
Path.Set.fold (fun p -> Ident.Set.union (collect_ids !subst !bindings p))
718718
!paths Ident.Set.empty
719719

720+
type remove_alias_from =
721+
| Alias of Ident.t
722+
| Strengthening
720723
type remove_alias_args =
721724
{ mutable modified: bool;
722-
exclude: Ident.t option -> Path.t -> bool;
725+
exclude: remove_alias_from -> Path.t -> bool;
723726
scrape: Env.t -> module_type -> module_type }
724727

725728
let rec remove_aliases_mty env args pres mty =
@@ -736,7 +739,7 @@ let rec remove_aliases_mty env args pres mty =
736739
args'.modified <- true;
737740
remove_aliases_mty env args' Mp_present mty'
738741
end
739-
| Mty_strengthen (mty,p,Aliasable) when not (args.exclude None p) ->
742+
| Mty_strengthen (mty,p,Aliasable) when not (args.exclude Strengthening p) ->
740743
let mty = strengthen ~aliasable:false mty p in
741744
args'.modified <- true;
742745
Mp_present, mty
@@ -756,7 +759,7 @@ and remove_aliases_sig env args sg =
756759
| Sig_module(id, pres, md, rs, priv) :: rem ->
757760
let pres, mty =
758761
match md.md_type with
759-
Mty_alias p when args.exclude (Some id) p ->
762+
Mty_alias p when args.exclude (Alias id) p ->
760763
pres, md.md_type
761764
| mty ->
762765
remove_aliases_mty env args pres mty
@@ -782,8 +785,8 @@ let scrape_for_type_of ~remove_aliases env mty =
782785
if remove_aliases then begin
783786
let excl = collect_arg_paths mty in
784787
let exclude id _p = match id with
785-
| Some id -> Ident.Set.mem id excl
786-
| None -> false
788+
| Alias id -> Ident.Set.mem id excl
789+
| Strengthening -> false
787790
in
788791
let scrape _ mty = mty in
789792
let _, mty =

0 commit comments

Comments
 (0)