Sfoglia il codice sorgente

[hl] don't do whatever this does when there's a HMethod

Simon Krajewski 1 anno fa
parent
commit
33fbf9b69e
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      src/generators/genhl.ml

+ 4 - 1
src/generators/genhl.ml

@@ -2361,8 +2361,11 @@ and eval_expr ctx e =
 		| HFun _ -> cast_to ctx r to_t e.epos
 		| HFun _ -> cast_to ctx r to_t e.epos
 		| _ -> unsafe_cast_to ctx r to_t e.epos)
 		| _ -> unsafe_cast_to ctx r to_t e.epos)
 	| TObjectDecl fl ->
 	| TObjectDecl fl ->
+		let has_method vp =
+			Array.exists (fun (_,_,t) -> match t with HMethod _ -> true | _ -> false) vp.vfields
+		in
 		(match to_type ctx e.etype with
 		(match to_type ctx e.etype with
-		| HVirtual vp as t when Array.length vp.vfields = List.length fl && not (List.exists (fun ((s,_,_),e) -> s = "toString" && is_to_string e.etype) fl)  ->
+		| HVirtual vp as t when Array.length vp.vfields = List.length fl && not (List.exists (fun ((s,_,_),e) -> s = "toString" && is_to_string e.etype) fl) && not (has_method vp) ->
 			let r = alloc_tmp ctx t in
 			let r = alloc_tmp ctx t in
 			op ctx (ONew r);
 			op ctx (ONew r);
 			hold ctx r;
 			hold ctx r;