浏览代码

[java/cs] Deal with new on @:generic code. Closes #1894

Caue Waneck 12 年之前
父节点
当前提交
d623dababb
共有 3 个文件被更改,包括 6 次插入0 次删除
  1. 2 0
      gencommon.ml
  2. 2 0
      gencs.ml
  3. 2 0
      genjava.ml

+ 2 - 0
gencommon.ml

@@ -5947,6 +5947,8 @@ struct
             | _ -> Type.map_expr run e
           )
         (* the TNew and TSuper code was modified at r6497 *)
+        | TNew ({ cl_kind = KTypeParameter _ }, _, _) ->
+          Type.map_expr run e
         | TNew (cl, tparams, eparams) -> (try
           let is_overload, cf, sup, stl = choose_ctor gen cl tparams (List.map (fun e -> e.etype) eparams) maybe_empty_t e.epos in
           let handle e t1 t2 =

+ 2 - 0
gencs.ml

@@ -1120,6 +1120,8 @@ let configure gen =
             acc + 1
           ) 0 el);
           write w ")"
+        | TNew ({ cl_kind = KTypeParameter _ } as cl, params, el) ->
+          print w "default(%s) /* This code should never be reached. It was produced by the use of @:generic on a new type parameter instance: %s */" (t_s (TInst(cl,params))) (path_param_s (TClassDecl cl) cl.cl_path params)
         | TNew (cl, params, el) ->
           write w "new ";
           write w (path_param_s (TClassDecl cl) cl.cl_path params);

+ 2 - 0
genjava.ml

@@ -1239,6 +1239,8 @@ let configure gen =
             acc + 1
           ) 0 el);
           write w ")"
+        | TNew ({ cl_kind = KTypeParameter _ } as cl, params, el) ->
+          print w "null /* This code should never be reached. It was produced by the use of @:generic on a new type parameter instance: %s */" (path_param_s e.epos (TClassDecl cl) cl.cl_path params)
         | TNew (cl, params, el) ->
           write w "new ";
           write w (path_param_s e.epos (TClassDecl cl) cl.cl_path params);