|
@@ -4231,19 +4231,28 @@ let make_macro_api ctx p =
|
|
);
|
|
);
|
|
Interp.define_type = (fun v ->
|
|
Interp.define_type = (fun v ->
|
|
let m, tdef, pos = (try Interp.decode_type_def v with Interp.Invalid_expr -> Interp.exc (Interp.VString "Invalid type definition")) in
|
|
let m, tdef, pos = (try Interp.decode_type_def v with Interp.Invalid_expr -> Interp.exc (Interp.VString "Invalid type definition")) in
|
|
- let prev = (try Some (Hashtbl.find ctx.g.modules m) with Not_found -> None) in
|
|
|
|
- let mnew = Typeload.type_module ctx m ctx.m.curmod.m_extra.m_file [tdef,pos] pos in
|
|
|
|
- add_dependency mnew ctx.m.curmod;
|
|
|
|
- (* if we defined a type in an existing module, let's move the types here *)
|
|
|
|
- (match prev with
|
|
|
|
- | None ->
|
|
|
|
- mnew.m_extra.m_kind <- MFake;
|
|
|
|
- | Some mold ->
|
|
|
|
- Hashtbl.replace ctx.g.modules mnew.m_path mold;
|
|
|
|
- mold.m_types <- mold.m_types @ mnew.m_types;
|
|
|
|
- mnew.m_extra.m_kind <- MSub;
|
|
|
|
- add_dependency mold mnew;
|
|
|
|
- );
|
|
|
|
|
|
+ let add ctx =
|
|
|
|
+ let prev = (try Some (Hashtbl.find ctx.g.modules m) with Not_found -> None) in
|
|
|
|
+ let mnew = Typeload.type_module ctx m ctx.m.curmod.m_extra.m_file [tdef,pos] pos in
|
|
|
|
+ add_dependency mnew ctx.m.curmod;
|
|
|
|
+ (* if we defined a type in an existing module, let's move the types here *)
|
|
|
|
+ (match prev with
|
|
|
|
+ | None ->
|
|
|
|
+ mnew.m_extra.m_kind <- MFake;
|
|
|
|
+ | Some mold ->
|
|
|
|
+ Hashtbl.replace ctx.g.modules mnew.m_path mold;
|
|
|
|
+ mold.m_types <- mold.m_types @ mnew.m_types;
|
|
|
|
+ mnew.m_extra.m_kind <- MSub;
|
|
|
|
+ add_dependency mold mnew;
|
|
|
|
+ );
|
|
|
|
+ in
|
|
|
|
+ add ctx;
|
|
|
|
+ (* if we are adding a class which has a macro field, we also have to add it to the macro context (issue #1497) *)
|
|
|
|
+ if not ctx.in_macro then match tdef,ctx.g.macros with
|
|
|
|
+ | EClass c,Some (_,mctx) when List.exists (fun cff -> (Meta.has Meta.Macro cff.cff_meta || List.mem AMacro cff.cff_access)) c.d_data ->
|
|
|
|
+ add mctx
|
|
|
|
+ | _ ->
|
|
|
|
+ ()
|
|
);
|
|
);
|
|
Interp.define_module = (fun m types ->
|
|
Interp.define_module = (fun m types ->
|
|
let types = List.map (fun v ->
|
|
let types = List.map (fun v ->
|