Skip to content

Commit

Permalink
support importing module-level statics
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako committed Feb 16, 2020
1 parent 2d7bc8e commit f0fd752
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/typing/typeloadModule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,28 @@ let init_module_type ctx context_init (decl,p) =
ctx.m.module_types <- ((match name with None -> tsub | Some(n,pname) -> rebind tsub n pname),p) :: ctx.m.module_types
with Not_found ->
(* this might be a static property, wait later to check *)
let tmain = get_type tname in
context_init#add (fun() ->
let find_main_type_static () =
let tmain = get_type tname in
try
add_static_init tmain name tsub
with Not_found ->
(* TODO: mention module-level declarations in the error message? *)
display_error ctx (s_type_path (t_infos tmain).mt_path ^ " has no field or subtype " ^ tsub) p
))
in
context_init#add (fun() ->
match md.m_statics with
| Some c ->
(try
ignore(c.cl_build());
let _ = List.find (fun cf -> cf.cf_name = tsub) c.cl_ordered_statics in
let imported_name = match name with None -> tsub | Some (n,pname) -> n in
ctx.m.module_globals <- PMap.add imported_name (TClassDecl c,tsub,p) ctx.m.module_globals;
with Not_found ->
find_main_type_static ())
| None ->
find_main_type_static ()
)
)
| (tsub,p2) :: (fname,p3) :: rest ->
(match rest with
| [] -> ()
Expand Down

0 comments on commit f0fd752

Please sign in to comment.