Quellcode durchsuchen

[java/cs] Made Type Parameter detection more robust by checking super classes as well. Fixed Issue #942

Caue Waneck vor 13 Jahren
Ursprung
Commit
b0d94a68d8
1 geänderte Dateien mit 19 neuen und 1 gelöschten Zeilen
  1. 19 1
      gencommon.ml

+ 19 - 1
gencommon.ml

@@ -3442,7 +3442,25 @@ struct
         | TInst( ({ cl_kind = KTypeParameter } as cl ), []), _ ->
           Hashtbl.replace params_tbl cl.cl_path applied
         | TInst(cl, params), TInst(cl2, params2) ->
-          List.iter2 (get_arg) params params2
+          let rec loop cl2 params2 =
+            if cl == cl2 then
+              List.iter2 (get_arg) params params2
+            else begin
+              if not (List.exists (fun (cs,tls) ->
+                if (cs == cl) then begin
+                  loop cs (List.map (apply_params cl2.cl_types params2) tls);
+                  true
+                end else
+                  false
+              ) cl2.cl_implements) then
+                match cl2.cl_super with
+                  | None -> (* not related ! *) ()
+                  | Some (cs,tls) ->
+                    loop cs (List.map (apply_params cl2.cl_types params2) tls)
+            end
+          in
+          loop cl2 params2
+          
         | TEnum(e, params), TEnum(e2, params2) ->
           List.iter2 (get_arg) params params2
         | TFun(params, ret), TFun(params2, ret2) ->