Browse Source

[jvm] fix is_string detection

see #10523
Simon Krajewski 3 years ago
parent
commit
884026f832
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/generators/genjvm.ml

+ 7 - 2
src/generators/genjvm.ml

@@ -40,6 +40,11 @@ open Genshared
 let is_really_int t =
 let is_really_int t =
 	not (is_nullable t) && ExtType.is_int (follow t)
 	not (is_nullable t) && ExtType.is_int (follow t)
 
 
+(* Due to @:native, the usual String path doesn't match *)
+let is_string t = match t with
+| TInst({cl_path=([],"String") | (["java";"lang"],"String")},_) -> true
+| _ -> false
+
 let get_construction_mode c cf =
 let get_construction_mode c cf =
 	if Meta.has Meta.HxGen cf.cf_meta then ConstructInitPlusNew
 	if Meta.has Meta.HxGen cf.cf_meta then ConstructInitPlusNew
 	else ConstructInit
 	else ConstructInit
@@ -1809,12 +1814,12 @@ class texpr_to_jvm gctx (jc : JvmClass.builder) (jm : JvmMethod.builder) (return
 			| Not | Neg | NegBits when not (need_val ret) -> self#texpr ret e1
 			| Not | Neg | NegBits when not (need_val ret) -> self#texpr ret e1
 			| _ -> self#unop ret op flag e1
 			| _ -> self#unop ret op flag e1
 			end
 			end
-		| TBinop(OpAdd,e1,e2) when ExtType.is_string (follow e.etype) ->
+		| TBinop(OpAdd,e1,e2) when is_string (follow e.etype) ->
 			let string_builder_path = (["java";"lang"],"StringBuilder") in
 			let string_builder_path = (["java";"lang"],"StringBuilder") in
 			let string_builder_sig = object_path_sig string_builder_path in
 			let string_builder_sig = object_path_sig string_builder_path in
 			jm#construct ConstructInit string_builder_path (fun () -> []);
 			jm#construct ConstructInit string_builder_path (fun () -> []);
 			let rec loop e = match e.eexpr with
 			let rec loop e = match e.eexpr with
-				| TBinop(OpAdd,e1,e2) when ExtType.is_string (follow e.etype) ->
+				| TBinop(OpAdd,e1,e2) when is_string (follow e.etype) ->
 					loop e1;
 					loop e1;
 					loop e2;
 					loop e2;
 				| _ ->
 				| _ ->