[m-rev.] diff: Fix ADT violations.

Peter Wang novalazy at gmail.com
Sun Aug 20 11:19:45 AEST 2017


compiler/polymorphism.m:
    Construct vartypes using init_vartypes instead of map.init directly.

compiler/vartypes.m:
    Add foldl_var_types predicate.

compiler/unused_imports.m:
    Use foldl_var_types instead of map.foldl_values.
---
 compiler/polymorphism.m   | 2 +-
 compiler/unused_imports.m | 3 ++-
 compiler/vartypes.m       | 6 ++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/compiler/polymorphism.m b/compiler/polymorphism.m
index 6d42ccd..02d212f 100644
--- a/compiler/polymorphism.m
+++ b/compiler/polymorphism.m
@@ -657,7 +657,7 @@ polymorphism_process_clause_info(ModuleInfo0, PredInfo0, !ClausesInfo, !:Info,
     poly_info_get_var_types(!.Info, VarTypes),
     poly_info_get_rtti_varmaps(!.Info, RttiVarMaps),
     set_clause_list(Clauses, ClausesRep),
-    map.init(TVarNameMap), % This is only used while adding the clauses.
+    init_vartypes(TVarNameMap), % This is only used while adding the clauses.
     !:ClausesInfo = clauses_info(VarSet, ExplicitVarTypes, TVarNameMap,
         VarTypes, HeadVars, ClausesRep, ItemNumbers,
         RttiVarMaps, HaveForeignClauses, HadSyntaxErrors).
diff --git a/compiler/unused_imports.m b/compiler/unused_imports.m
index ee8ed71..3b2c651 100644
--- a/compiler/unused_imports.m
+++ b/compiler/unused_imports.m
@@ -53,6 +53,7 @@
 :- import_module hlds.hlds_goal.
 :- import_module hlds.hlds_pred.
 :- import_module hlds.status.
+:- import_module hlds.vartypes.
 :- import_module mdbcomp.
 :- import_module mdbcomp.builtin_modules.
 :- import_module mdbcomp.sym_name.
@@ -659,7 +660,7 @@ proc_info_used_modules(Visibility, _ProcId, ProcInfo, !UsedModules) :-
     % given that the average number of proc_infos per pred_info typically
     % hovers in the 1.01-to-1.2 range.
     proc_info_get_vartypes(ProcInfo, VarTypes),
-    map.foldl_values(mer_type_used_modules(Visibility), VarTypes,
+    foldl_var_types(mer_type_used_modules(Visibility), VarTypes,
         !UsedModules),
 
     proc_info_get_maybe_declared_argmodes(ProcInfo, MaybeArgModes),
diff --git a/compiler/vartypes.m b/compiler/vartypes.m
index 33e76ea..a0baaff 100644
--- a/compiler/vartypes.m
+++ b/compiler/vartypes.m
@@ -89,6 +89,9 @@
     pred(mer_type, mer_type, T, T)::in(pred(in, out, in, out) is det),
     vartypes::in, vartypes::out, T::in, T::out) is det.
 
+:- pred foldl_var_types(pred(mer_type, T, T)::in(pred(in, in, out) is det),
+    vartypes::in, T::in, T::out) is det.
+
 :- type prog_var_set_types
     --->    prog_var_set_types(prog_varset, vartypes).
 
@@ -202,6 +205,9 @@ transform_var_types(Transform, !VarTypes) :-
 transform_foldl_var_types(Transform, !VarTypes, !Acc) :-
     map.map_values_foldl(Transform, !VarTypes, !Acc).
 
+foldl_var_types(Pred, VarTypes, !Acc) :-
+    map.foldl_values(Pred, VarTypes, !Acc).
+
 %---------------------------------------------------------------------------%
 :- end_module hlds.vartypes.
 %---------------------------------------------------------------------------%
-- 
2.9.0



More information about the reviews mailing list