|
@@ -201,6 +201,10 @@ let extend_remoting ctx c t p async prot =
|
|
(* -------------------------------------------------------------------------- *)
|
|
(* -------------------------------------------------------------------------- *)
|
|
(* HAXE.RTTI.GENERIC *)
|
|
(* HAXE.RTTI.GENERIC *)
|
|
|
|
|
|
|
|
+let recursive_usage_error ctx p p2 =
|
|
|
|
+ display_error ctx "Recursive generics may not use their type parameters as values" p;
|
|
|
|
+ error "Class was used recursively here" p2
|
|
|
|
+
|
|
let rec build_generic ctx c p tl =
|
|
let rec build_generic ctx c p tl =
|
|
let pack = fst c.cl_path in
|
|
let pack = fst c.cl_path in
|
|
let recurse = ref false in
|
|
let recurse = ref false in
|
|
@@ -225,7 +229,12 @@ let rec build_generic ctx c p tl =
|
|
| l , name -> String.concat "_" l ^ "_" ^ name
|
|
| l , name -> String.concat "_" l ^ "_" ^ name
|
|
) tl)) in
|
|
) tl)) in
|
|
if !recurse then
|
|
if !recurse then
|
|
- TInst (c,tl) (* build a normal instance *)
|
|
|
|
|
|
+ (try
|
|
|
|
+ let (_,_,p2) = get_meta ":genericT" c.cl_meta in
|
|
|
|
+ recursive_usage_error ctx p2 p;
|
|
|
|
+ with Not_found ->
|
|
|
|
+ if not (has_meta ":usedRecursively" c.cl_meta) then c.cl_meta <- (":usedRecursively",[],p) :: c.cl_meta;
|
|
|
|
+ TInst (c,tl)) (* build a normal instance *)
|
|
else try
|
|
else try
|
|
Typeload.load_instance ctx { tpackage = pack; tname = name; tparams = []; tsub = None } p false
|
|
Typeload.load_instance ctx { tpackage = pack; tname = name; tparams = []; tsub = None } p false
|
|
with Error(Module_not_found path,_) when path = (pack,name) ->
|
|
with Error(Module_not_found path,_) when path = (pack,name) ->
|
|
@@ -596,7 +605,7 @@ let on_generate ctx t =
|
|
let rpath = (fst c.cl_module.m_path,"_" ^ snd c.cl_module.m_path) in
|
|
let rpath = (fst c.cl_module.m_path,"_" ^ snd c.cl_module.m_path) in
|
|
if Hashtbl.mem ctx.g.types_module rpath then error ("This private class name will clash with " ^ s_type_path rpath) c.cl_pos;
|
|
if Hashtbl.mem ctx.g.types_module rpath then error ("This private class name will clash with " ^ s_type_path rpath) c.cl_pos;
|
|
end;
|
|
end;
|
|
- if c.cl_kind = KGeneric then c.cl_extern <- true;
|
|
|
|
|
|
+ if c.cl_kind = KGeneric && not (has_meta ":usedRecursively" c.cl_meta) then c.cl_extern <- true;
|
|
c.cl_restore <- restore c;
|
|
c.cl_restore <- restore c;
|
|
List.iter (fun m ->
|
|
List.iter (fun m ->
|
|
match m with
|
|
match m with
|