Browse Source

[java/cs] Fixed GADT handling and failed cast detection for returns on statements.
fixed issue #1580

Caue Waneck 12 years ago
parent
commit
ec4346a378
4 changed files with 1447 additions and 1411 deletions
  1. 1434 1400
      gencommon.ml
  2. 5 6
      gencs.ml
  3. 8 3
      genjava.ml
  4. 0 2
      tests/unit/Test.hx

File diff suppressed because it is too large
+ 1434 - 1400
gencommon.ml


+ 5 - 6
gencs.ml

@@ -247,7 +247,7 @@ struct
 
 
   let name = "csharp_specific"
   let name = "csharp_specific"
 
 
-  let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority; DBefore IntDivisionSynf.priority; DAfter HardNullableSynf.priority ]
+  let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority;  DAfter HardNullableSynf.priority ]
 
 
   let get_cl_from_t t =
   let get_cl_from_t t =
     match follow t with
     match follow t with
@@ -619,12 +619,11 @@ let configure gen =
         has_tdyn params &&
         has_tdyn params &&
         Hashtbl.mem ifaces cl.cl_path ->
         Hashtbl.mem ifaces cl.cl_path ->
           TInst(Hashtbl.find ifaces cl.cl_path, [])
           TInst(Hashtbl.find ifaces cl.cl_path, [])
-      | TEnum(e, params) when
-        has_tdyn params &&
-        Hashtbl.mem ifaces e.e_path ->
-          TInst(Hashtbl.find ifaces e.e_path, [])
+      | TEnum(e, params) ->
+        TEnum(e, List.map (fun _ -> t_dynamic) params)
+      | TInst(cl, params) when Meta.has Meta.Enum cl.cl_meta ->
+        TInst(cl, List.map (fun _ -> t_dynamic) params)
       | TInst(cl, params) -> TInst(cl, change_param_type (TClassDecl cl) params)
       | TInst(cl, params) -> TInst(cl, change_param_type (TClassDecl cl) params)
-      | TEnum(e, params) -> TEnum(e, change_param_type (TEnumDecl e) params)
       | TType({ t_path = ([], "Null") }, [t]) ->
       | TType({ t_path = ([], "Null") }, [t]) ->
         (*
         (*
           Null<> handling is a little tricky.
           Null<> handling is a little tricky.

+ 8 - 3
genjava.ml

@@ -801,7 +801,9 @@ let configure gen =
       | TAbstract( { a_path = ([], "Enum") }, p  )
       | TAbstract( { a_path = ([], "Enum") }, p  )
       | TInst( { cl_path = ([], "Class") }, p  )
       | TInst( { cl_path = ([], "Class") }, p  )
       | TInst( { cl_path = ([], "Enum") }, p  ) -> TInst(cl_cl,p)
       | TInst( { cl_path = ([], "Enum") }, p  ) -> TInst(cl_cl,p)
-      | TEnum _
+      | TEnum(e,params) -> TEnum(e, List.map (fun _ -> t_dynamic) params)
+      | TInst(c,params) when Meta.has Meta.Enum c.cl_meta ->
+        TInst(c, List.map (fun _ -> t_dynamic) params)
       | TInst _ -> t
       | TInst _ -> t
       | TType({ t_path = ([], "Null") }, [t]) when is_java_basic_type t -> t_dynamic
       | TType({ t_path = ([], "Null") }, [t]) when is_java_basic_type t -> t_dynamic
       | TType({ t_path = ([], "Null") }, [t]) ->
       | TType({ t_path = ([], "Null") }, [t]) ->
@@ -917,7 +919,10 @@ let configure gen =
       | TAbstract ({ a_path = [], "Class" }, _) | TAbstract ({ a_path = [], "Enum" }, _)
       | TAbstract ({ a_path = [], "Class" }, _) | TAbstract ({ a_path = [], "Enum" }, _)
       | TInst ({ cl_path = [], "Class" }, _) | TInst ({ cl_path = [], "Enum" }, _) ->
       | TInst ({ cl_path = [], "Class" }, _) | TInst ({ cl_path = [], "Enum" }, _) ->
           path_s_import pos (["java";"lang"], "Class")
           path_s_import pos (["java";"lang"], "Class")
-      | TEnum (({e_path = p;} as e), params) -> (path_param_s pos (TEnumDecl e) p params)
+      | TEnum ({e_path = p}, _) ->
+          path_s_import pos p
+      | TInst (({cl_path = p;} as cl), _) when Meta.has Meta.Enum cl.cl_meta ->
+          path_s_import pos p
       | TInst (({cl_path = p;} as cl), params) -> (path_param_s pos (TClassDecl cl) p params)
       | TInst (({cl_path = p;} as cl), params) -> (path_param_s pos (TClassDecl cl) p params)
       | TType (({t_path = p;} as t), params) -> (path_param_s pos (TTypeDecl t) p params)
       | TType (({t_path = p;} as t), params) -> (path_param_s pos (TTypeDecl t) p params)
       | TAnon (anon) ->
       | TAnon (anon) ->
@@ -1769,7 +1774,7 @@ let configure gen =
 
 
   ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (get_cl (get_type gen (["haxe";"lang"],"Function")) ));
   ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (get_cl (get_type gen (["haxe";"lang"],"Function")) ));
 
 
-  EnumToClass.configure gen (None) false true (get_cl (get_type gen (["haxe";"lang"],"Enum")) ) false true;
+  EnumToClass.configure gen (None) false true (get_cl (get_type gen (["haxe";"lang"],"Enum")) ) false false;
 
 
   InterfaceVarsDeleteModf.configure gen;
   InterfaceVarsDeleteModf.configure gen;
 
 

+ 0 - 2
tests/unit/Test.hx

@@ -237,9 +237,7 @@ class Test #if swf_mark implements mt.Protect #end {
 			new TestMeta(),
 			new TestMeta(),
 			new TestType(),
 			new TestType(),
 			new TestOrder(),
 			new TestOrder(),
-			#if (!java && !cs)
 			new TestGADT(),
 			new TestGADT(),
-			#end
 			#if !no_pattern_matching
 			#if !no_pattern_matching
 			new TestMatch(),
 			new TestMatch(),
 			#end
 			#end

Some files were not shown because too many files changed in this diff