Explorar o código

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

Caue Waneck %!s(int64=12) %!d(string=hai) anos
pai
achega
d623dababb
Modificáronse 3 ficheiros con 6 adicións e 0 borrados
  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);