Skip to content

Commit

Permalink
create class context earlier to avoid some heritage awkwardness
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Jan 31, 2024
1 parent 98c9171 commit 97a0be7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/typing/typeloadCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ module Inheritance = struct

let set_heritance ctx c herits p =
let is_lib = Meta.has Meta.LibType c.cl_meta in
let ctx = { ctx with c = {ctx.c with curclass = c}; type_params = c.cl_params; } in
let old_meta = c.cl_meta in
let process_meta csup =
List.iter (fun m ->
Expand Down
4 changes: 1 addition & 3 deletions src/typing/typeloadFields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1732,9 +1732,7 @@ let check_functional_interface ctx c =
add_class_flag c CFunctionalInterface;
ctx.g.functional_interface_lut#add c.cl_path cf

let init_class ctx c p herits fields =
let cctx = create_class_context c p in
let ctx = create_typer_context_for_class ctx cctx p in
let init_class ctx cctx c p herits fields =
if cctx.is_class_debug then print_endline ("Created class context: " ^ dump_class_context cctx);
let fields = patch_class ctx c fields in
let fields = build_fields (ctx,cctx) c fields in
Expand Down
4 changes: 3 additions & 1 deletion src/typing/typeloadModule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,14 @@ module TypeLevel = struct
let prev_build_count = ref (ctx.g.build_count - 1) in
let build() =
c.cl_build <- (fun()-> Building [c]);
let cctx = TypeloadFields.create_class_context c p in
let ctx = TypeloadFields.create_typer_context_for_class ctx cctx p in
let fl = TypeloadCheck.Inheritance.set_heritance ctx c herits p in
let rec build() =
c.cl_build <- (fun()-> Building [c]);
try
List.iter (fun f -> f()) fl;
TypeloadFields.init_class ctx c p d.d_flags d.d_data;
TypeloadFields.init_class ctx cctx c p d.d_flags d.d_data;
c.cl_build <- (fun()-> Built);
ctx.g.build_count <- ctx.g.build_count + 1;
List.iter (fun tp -> ignore(follow tp.ttp_type)) c.cl_params;
Expand Down

0 comments on commit 97a0be7

Please sign in to comment.