Browse Source

Merge branch 'development' of github.com:HaxeFoundation/haxe into development

Alexander Kuzmenko 8 years ago
parent
commit
8bede5ea18
100 changed files with 887 additions and 516 deletions
  1. 1 0
      .travis.yml
  2. 1 1
      Makefile
  3. 2 1
      src/compiler/main.ml
  4. 2 0
      src/context/common.ml
  5. 13 12
      src/display/display.ml
  6. 16 8
      src/display/displayOutput.ml
  7. 1 1
      src/generators/gencommon.ml
  8. 37 18
      src/generators/gencommon/castDetect.ml
  9. 24 6
      src/generators/gencommon/dynamicFieldAccess.ml
  10. 2 3
      src/generators/gencommon/dynamicOperators.ml
  11. 2 2
      src/generators/gencommon/reflectionCFs.ml
  12. 5 2
      src/generators/gencommon/setHXGen.ml
  13. 45 8
      src/generators/gencs.ml
  14. 279 68
      src/generators/genjava.ml
  15. 2 3
      src/generators/genlua.ml
  16. 31 6
      src/macro/eval/evalStdLib.ml
  17. 1 1
      src/optimization/dce.ml
  18. 19 11
      src/syntax/lexer.ml
  19. 5 3
      src/syntax/parser.mly
  20. 12 4
      src/typing/matcher.ml
  21. 80 115
      src/typing/type.ml
  22. 2 2
      src/typing/typeload.ml
  23. 3 1
      std/cs/_std/haxe/ds/IntMap.hx
  24. 3 1
      std/cs/_std/haxe/ds/ObjectMap.hx
  25. 2 0
      std/cs/_std/haxe/ds/StringMap.hx
  26. 0 3
      std/haxe/CallStack.hx
  27. 11 0
      std/haxe/ds/GenericStack.hx
  28. 44 105
      std/java/_std/Type.hx
  29. 3 1
      std/java/_std/haxe/ds/IntMap.hx
  30. 4 2
      std/java/_std/haxe/ds/ObjectMap.hx
  31. 3 2
      std/java/_std/haxe/ds/WeakMap.hx
  32. 38 5
      std/java/internal/Runtime.hx
  33. 1 1
      std/java/lang/Double.hx
  34. 1 1
      std/java/lang/Float.hx
  35. 1 1
      std/java/lang/Integer.hx
  36. 1 1
      std/java/lang/Short.hx
  37. 9 2
      std/lua/_std/String.hx
  38. 4 4
      std/php7/_std/sys/db/Mysql.hx
  39. 1 1
      tests/display/src/File.hx
  40. 22 0
      tests/display/src/cases/Issue6381.hx
  41. 20 0
      tests/display/src/cases/Issue6396.hx
  42. 24 0
      tests/display/src/cases/Toplevel.hx
  43. 1 1
      tests/misc/projects/Issue1138/compile3-fail.hxml.stderr
  44. 1 1
      tests/misc/projects/Issue1138/compile4-fail.hxml.stderr
  45. 2 2
      tests/misc/projects/Issue1310/compile1-fail.hxml.stderr
  46. 1 1
      tests/misc/projects/Issue1968/compile.hxml.stderr
  47. 1 1
      tests/misc/projects/Issue2087/compile-fail.hxml.stderr
  48. 2 2
      tests/misc/projects/Issue2148/compile1-fail.hxml.stderr
  49. 2 2
      tests/misc/projects/Issue2232/compile1-fail.hxml.stderr
  50. 1 1
      tests/misc/projects/Issue2232/compile2-fail.hxml.stderr
  51. 10 10
      tests/misc/projects/Issue2508/compile.hxml.stderr
  52. 1 1
      tests/misc/projects/Issue2538/compile-fail.hxml.stderr
  53. 1 1
      tests/misc/projects/Issue2991/compile.hxml.stderr
  54. 1 1
      tests/misc/projects/Issue2993/compile.hxml.stderr
  55. 1 1
      tests/misc/projects/Issue2995/position.hxml.stderr
  56. 2 2
      tests/misc/projects/Issue2995/usage.hxml.stderr
  57. 1 1
      tests/misc/projects/Issue2996/compile1.hxml.stderr
  58. 1 1
      tests/misc/projects/Issue2996/compile2.hxml.stderr
  59. 1 1
      tests/misc/projects/Issue2997/compile1.hxml.stderr
  60. 3 3
      tests/misc/projects/Issue3192/compile1-fail.hxml.stderr
  61. 1 1
      tests/misc/projects/Issue3238/default-value-fail.hxml.stderr
  62. 1 1
      tests/misc/projects/Issue3238/non-extern-fail.hxml.stderr
  63. 1 1
      tests/misc/projects/Issue3238/not-last-fail.hxml.stderr
  64. 1 1
      tests/misc/projects/Issue3238/optional-fail.hxml.stderr
  65. 1 1
      tests/misc/projects/Issue3361/compile1-fail.hxml.stderr
  66. 4 4
      tests/misc/projects/Issue3361/compile2-fail.hxml.stderr
  67. 3 3
      tests/misc/projects/Issue3417/compile-fail.hxml.stderr
  68. 1 1
      tests/misc/projects/Issue3457/compile-fail.hxml.stderr
  69. 1 1
      tests/misc/projects/Issue3621/compile-fail.hxml.stderr
  70. 3 3
      tests/misc/projects/Issue3678/compile-fail.hxml.stderr
  71. 2 2
      tests/misc/projects/Issue3699/compile-var-fail.hxml.stderr
  72. 1 1
      tests/misc/projects/Issue3710/compile-1-fail.hxml.stderr
  73. 1 1
      tests/misc/projects/Issue3710/compile-2-fail.hxml.stderr
  74. 1 1
      tests/misc/projects/Issue3714/compile-fail.hxml.stderr
  75. 1 1
      tests/misc/projects/Issue3726/compile-1-fail.hxml.stderr
  76. 1 1
      tests/misc/projects/Issue3726/compile-2-fail.hxml.stderr
  77. 2 2
      tests/misc/projects/Issue3781/compile-fail.hxml.stderr
  78. 1 1
      tests/misc/projects/Issue3783/compile-fail.hxml.stderr
  79. 1 1
      tests/misc/projects/Issue3802/compile-fail.hxml.stderr
  80. 1 1
      tests/misc/projects/Issue3830/compile-fail.hxml.stderr
  81. 2 2
      tests/misc/projects/Issue3975/compile-fail.hxml.stderr
  82. 1 1
      tests/misc/projects/Issue4114/compile1-fail.hxml.stderr
  83. 1 1
      tests/misc/projects/Issue4247/compile-fail.hxml.stderr
  84. 5 5
      tests/misc/projects/Issue4250/compile-fail.hxml.stderr
  85. 1 1
      tests/misc/projects/Issue4293/compile-abstract-fail.hxml.stderr
  86. 1 1
      tests/misc/projects/Issue4293/compile-class-fail.hxml.stderr
  87. 1 1
      tests/misc/projects/Issue4293/compile-enum-ctor-fail.hxml.stderr
  88. 1 1
      tests/misc/projects/Issue4293/compile-enum-fail.hxml.stderr
  89. 1 1
      tests/misc/projects/Issue4293/compile-field-fail.hxml.stderr
  90. 1 1
      tests/misc/projects/Issue4293/compile-typedef-fail.hxml.stderr
  91. 2 2
      tests/misc/projects/Issue4364/compile-fail.hxml.stderr
  92. 1 1
      tests/misc/projects/Issue4370/compile-fail.hxml.stderr
  93. 1 1
      tests/misc/projects/Issue4378/compile-fail.hxml.stderr
  94. 3 3
      tests/misc/projects/Issue4448/compile1-fail.hxml.stderr
  95. 1 1
      tests/misc/projects/Issue4466/compile-fail.hxml.stderr
  96. 4 4
      tests/misc/projects/Issue4540/compile-fail.hxml.stderr
  97. 1 1
      tests/misc/projects/Issue4671/compile1-fail.hxml.stderr
  98. 1 1
      tests/misc/projects/Issue4671/compile2-fail.hxml.stderr
  99. 1 1
      tests/misc/projects/Issue4689/compile-fail.hxml.stderr
  100. 18 18
      tests/misc/projects/Issue4720/compile.hxml.stderr

+ 1 - 0
.travis.yml

@@ -57,6 +57,7 @@ install_linux: &install_linux
     fi
     fi
   # Install dependencies
   # Install dependencies
   - export APT_CACHE_DIR=~/apt-cache && mkdir -pv $APT_CACHE_DIR
   - export APT_CACHE_DIR=~/apt-cache && mkdir -pv $APT_CACHE_DIR
+  - sudo apt-get install --reinstall ca-certificates # workaround for "Cannot add PPA: 'ppa:haxe/ocaml'. Please check that the PPA name or format is correct."
   - sudo add-apt-repository ppa:haxe/ocaml -y
   - sudo add-apt-repository ppa:haxe/ocaml -y
   - sudo apt-get update -y
   - sudo apt-get update -y
   - sudo apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y
   - sudo apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y

+ 1 - 1
Makefile

@@ -119,7 +119,7 @@ else
 	echo let version_extra = None > _build/src/compiler/version.ml
 	echo let version_extra = None > _build/src/compiler/version.ml
 endif
 endif
 
 
-build_src:build_dirs $(BUILD_SRC) _build/src/syntax/parser.ml _build/src/compiler/version.ml
+build_src: | build_dirs $(BUILD_SRC) _build/src/syntax/parser.ml _build/src/compiler/version.ml
 
 
 haxe: build_src
 haxe: build_src
 	$(MAKE) -f $(MAKEFILENAME) build_pass_1
 	$(MAKE) -f $(MAKEFILENAME) build_pass_1

+ 2 - 1
src/compiler/main.ml

@@ -758,6 +758,7 @@ try
 		com.warning <- if com.display.dms_error_policy = EPCollect then (fun s p -> add_diagnostics_message com s p DisplayTypes.DiagnosticsSeverity.Warning) else message ctx;
 		com.warning <- if com.display.dms_error_policy = EPCollect then (fun s p -> add_diagnostics_message com s p DisplayTypes.DiagnosticsSeverity.Warning) else message ctx;
 		com.error <- error ctx;
 		com.error <- error ctx;
 	end;
 	end;
+	Lexer.zero_based_columns := Common.defined com Define.OldErrorFormat;
 	DisplayOutput.process_display_file com classes;
 	DisplayOutput.process_display_file com classes;
 	let ext = Initialize.initialize_target ctx com classes in
 	let ext = Initialize.initialize_target ctx com classes in
 	(* if we are at the last compilation step, allow all packages accesses - in case of macros or opening another project file *)
 	(* if we are at the last compilation step, allow all packages accesses - in case of macros or opening another project file *)
@@ -774,7 +775,7 @@ try
 			("--help-metas", Arg.Unit (fun () -> ()),": print help for all compiler metadatas");
 			("--help-metas", Arg.Unit (fun () -> ()),": print help for all compiler metadatas");
 			("<dot-path>", Arg.Unit (fun () -> ()),": compile the module specified by dot-path");
 			("<dot-path>", Arg.Unit (fun () -> ()),": compile the module specified by dot-path");
 		] in
 		] in
-		if !cmds = [] && not !did_something then Arg.usage help_spec usage;
+		if !cmds = [] && not !did_something then print_endline (Arg.usage_string help_spec usage);
 	end else begin
 	end else begin
 		ctx.setup();
 		ctx.setup();
 		Common.log com ("Classpath : " ^ (String.concat ";" com.class_path));
 		Common.log com ("Classpath : " ^ (String.concat ";" com.class_path));

+ 2 - 0
src/context/common.ml

@@ -525,6 +525,7 @@ module Define = struct
 		| NoTraces
 		| NoTraces
 		| Objc
 		| Objc
 		| OldConstructorInline
 		| OldConstructorInline
+		| OldErrorFormat
 		| PhpPrefix
 		| PhpPrefix
 		| RealPosition
 		| RealPosition
 		| ReplaceFiles
 		| ReplaceFiles
@@ -627,6 +628,7 @@ module Define = struct
 		| NoTraces -> ("no_traces","Disable all trace calls")
 		| NoTraces -> ("no_traces","Disable all trace calls")
 		| Objc -> ("objc","Sets the hxcpp output to objective-c++ classes. Must be defined for interop")
 		| Objc -> ("objc","Sets the hxcpp output to objective-c++ classes. Must be defined for interop")
 		| OldConstructorInline -> ("old-constructor-inline","Use old constructor inlining logic (from haxe 3.4.2) instead of the reworked version.")
 		| OldConstructorInline -> ("old-constructor-inline","Use old constructor inlining logic (from haxe 3.4.2) instead of the reworked version.")
+		| OldErrorFormat -> ("old-error-format", "Use Haxe 3.x zero-based column error messages instead of new one-based format.")
 		| PhpPrefix -> ("php_prefix","Compiled with --php-prefix")
 		| PhpPrefix -> ("php_prefix","Compiled with --php-prefix")
 		| RealPosition -> ("real_position","Disables Haxe source mapping when targetting C#, removes position comments in Java and Php7 output")
 		| RealPosition -> ("real_position","Disables Haxe source mapping when targetting C#, removes position comments in Java and Php7 output")
 		| ReplaceFiles -> ("replace_files","GenCommon internal")
 		| ReplaceFiles -> ("replace_files","GenCommon internal")

+ 13 - 12
src/display/display.ml

@@ -786,19 +786,20 @@ module ToplevelCollector = struct
 
 
 	let run ctx only_types =
 	let run ctx only_types =
 		let acc = DynArray.create () in
 		let acc = DynArray.create () in
+		let add x = DynArray.add acc x in
 
 
 		if not only_types then begin
 		if not only_types then begin
 			(* locals *)
 			(* locals *)
 			PMap.iter (fun _ v ->
 			PMap.iter (fun _ v ->
 				if not (is_gen_local v) then
 				if not (is_gen_local v) then
-					DynArray.add acc (ITLocal v)
+					add (ITLocal v)
 			) ctx.locals;
 			) ctx.locals;
 
 
 			(* member vars *)
 			(* member vars *)
 			if ctx.curfun <> FunStatic then begin
 			if ctx.curfun <> FunStatic then begin
 				let rec loop c =
 				let rec loop c =
 					List.iter (fun cf ->
 					List.iter (fun cf ->
-						DynArray.add acc (ITMember(ctx.curclass,cf))
+						add (ITMember(ctx.curclass,cf))
 					) c.cl_ordered_fields;
 					) c.cl_ordered_fields;
 					match c.cl_super with
 					match c.cl_super with
 						| None ->
 						| None ->
@@ -812,7 +813,7 @@ module ToplevelCollector = struct
 
 
 			(* statics *)
 			(* statics *)
 			List.iter (fun cf ->
 			List.iter (fun cf ->
-				DynArray.add acc (ITStatic(ctx.curclass,cf))
+				add (ITStatic(ctx.curclass,cf))
 			) ctx.curclass.cl_ordered_statics;
 			) ctx.curclass.cl_ordered_statics;
 
 
 			(* enum constructors *)
 			(* enum constructors *)
@@ -820,7 +821,7 @@ module ToplevelCollector = struct
 				match t with
 				match t with
 				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
 				| TAbstractDecl ({a_impl = Some c} as a) when Meta.has Meta.Enum a.a_meta ->
 					List.iter (fun cf ->
 					List.iter (fun cf ->
-						if (Meta.has Meta.Enum cf.cf_meta) then DynArray.add acc (ITEnumAbstract(a,cf));
+						if (Meta.has Meta.Enum cf.cf_meta) then add (ITEnumAbstract(a,cf));
 					) c.cl_ordered_statics
 					) c.cl_ordered_statics
 				| TClassDecl _ | TAbstractDecl _ ->
 				| TClassDecl _ | TAbstractDecl _ ->
 					()
 					()
@@ -831,7 +832,7 @@ module ToplevelCollector = struct
 					end
 					end
 				| TEnumDecl e ->
 				| TEnumDecl e ->
 					PMap.iter (fun _ ef ->
 					PMap.iter (fun _ ef ->
-						DynArray.add acc (ITEnum(e,ef))
+						add (ITEnum(e,ef))
 					) e.e_constrs;
 					) e.e_constrs;
 			in
 			in
 			List.iter enum_ctors ctx.m.curmod.m_types;
 			List.iter enum_ctors ctx.m.curmod.m_types;
@@ -846,15 +847,15 @@ module ToplevelCollector = struct
 						| TAbstractDecl {a_impl = Some c} -> (PMap.find s c.cl_statics).cf_type
 						| TAbstractDecl {a_impl = Some c} -> (PMap.find s c.cl_statics).cf_type
 						| _ -> raise Not_found
 						| _ -> raise Not_found
 					in
 					in
-					DynArray.add acc (ITGlobal(mt,s,t))
+					add (ITGlobal(mt,s,t))
 				with Not_found ->
 				with Not_found ->
 					()
 					()
 			) ctx.m.module_globals;
 			) ctx.m.module_globals;
 
 
 			(* literals *)
 			(* literals *)
-			DynArray.add acc (ITLiteral "null");
-			DynArray.add acc (ITLiteral "true");
-			DynArray.add acc (ITLiteral "false");
+			add (ITLiteral "null");
+			add (ITLiteral "true");
+			add (ITLiteral "false");
 		end;
 		end;
 
 
 		let module_types = ref [] in
 		let module_types = ref [] in
@@ -906,16 +907,16 @@ module ToplevelCollector = struct
 		explore_class_paths ctx class_paths false add_package (fun _ -> ()) add_type;
 		explore_class_paths ctx class_paths false add_package (fun _ -> ()) add_type;
 
 
 		List.iter (fun pack ->
 		List.iter (fun pack ->
-			DynArray.add acc (ITPackage pack)
+			add (ITPackage pack)
 		) !packages;
 		) !packages;
 
 
 		List.iter (fun mt ->
 		List.iter (fun mt ->
-			DynArray.add acc (ITType mt)
+			add (ITType mt)
 		) !module_types;
 		) !module_types;
 
 
 		(* type params *)
 		(* type params *)
 		List.iter (fun (_,t) ->
 		List.iter (fun (_,t) ->
-			DynArray.add acc (ITType (module_type_of_type t))
+			add (ITType (module_type_of_type t))
 		) ctx.type_params;
 		) ctx.type_params;
 
 
 		DynArray.to_list acc
 		DynArray.to_list acc

+ 16 - 8
src/display/displayOutput.ml

@@ -60,22 +60,30 @@ let print_toplevel il =
 	Buffer.add_string b "<il>\n";
 	Buffer.add_string b "<il>\n";
 	let s_type t = htmlescape (s_type (print_context()) t) in
 	let s_type t = htmlescape (s_type (print_context()) t) in
 	let s_doc d = maybe_print_doc d in
 	let s_doc d = maybe_print_doc d in
+	let identifiers = Hashtbl.create 0 in
+	let check_ident s =
+		if Hashtbl.mem identifiers s then false
+		else begin
+			Hashtbl.add identifiers s true;
+			true
+		end
+	in
 	List.iter (fun id -> match id with
 	List.iter (fun id -> match id with
 		| IdentifierType.ITLocal v ->
 		| IdentifierType.ITLocal v ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"local\" t=\"%s\">%s</i>\n" (s_type v.v_type) v.v_name);
+			if check_ident v.v_name then Buffer.add_string b (Printf.sprintf "<i k=\"local\" t=\"%s\">%s</i>\n" (s_type v.v_type) v.v_name);
 		| IdentifierType.ITMember(c,cf) ->
 		| IdentifierType.ITMember(c,cf) ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"member\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
+			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"member\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
 		| IdentifierType.ITStatic(c,cf) ->
 		| IdentifierType.ITStatic(c,cf) ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"static\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
+			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"static\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
 		| IdentifierType.ITEnum(en,ef) ->
 		| IdentifierType.ITEnum(en,ef) ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"enum\" t=\"%s\"%s>%s</i>\n" (s_type ef.ef_type) (s_doc ef.ef_doc) ef.ef_name);
+			if check_ident ef.ef_name then Buffer.add_string b (Printf.sprintf "<i k=\"enum\" t=\"%s\"%s>%s</i>\n" (s_type ef.ef_type) (s_doc ef.ef_doc) ef.ef_name);
 		| IdentifierType.ITEnumAbstract(a,cf) ->
 		| IdentifierType.ITEnumAbstract(a,cf) ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"enumabstract\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
+			if check_ident cf.cf_name then Buffer.add_string b (Printf.sprintf "<i k=\"enumabstract\" t=\"%s\"%s>%s</i>\n" (s_type cf.cf_type) (s_doc cf.cf_doc) cf.cf_name);
 		| IdentifierType.ITGlobal(mt,s,t) ->
 		| IdentifierType.ITGlobal(mt,s,t) ->
-			Buffer.add_string b (Printf.sprintf "<i k=\"global\" p=\"%s\" t=\"%s\">%s</i>\n" (s_type_path (t_infos mt).mt_path) (s_type t) s);
+			if check_ident s then Buffer.add_string b (Printf.sprintf "<i k=\"global\" p=\"%s\" t=\"%s\">%s</i>\n" (s_type_path (t_infos mt).mt_path) (s_type t) s);
 		| IdentifierType.ITType(mt) ->
 		| IdentifierType.ITType(mt) ->
 			let infos = t_infos mt in
 			let infos = t_infos mt in
-			Buffer.add_string b (Printf.sprintf "<i k=\"type\" p=\"%s\"%s>%s</i>\n" (s_type_path infos.mt_path) (s_doc infos.mt_doc) (snd infos.mt_path));
+			if check_ident (snd infos.mt_path) then Buffer.add_string b (Printf.sprintf "<i k=\"type\" p=\"%s\"%s>%s</i>\n" (s_type_path infos.mt_path) (s_doc infos.mt_doc) (snd infos.mt_path));
 		| IdentifierType.ITPackage s ->
 		| IdentifierType.ITPackage s ->
 			Buffer.add_string b (Printf.sprintf "<i k=\"package\">%s</i>\n" s)
 			Buffer.add_string b (Printf.sprintf "<i k=\"package\">%s</i>\n" s)
 		| IdentifierType.ITLiteral s ->
 		| IdentifierType.ITLiteral s ->
@@ -400,7 +408,7 @@ let pos_to_json_range p =
 		JNull
 		JNull
 	else
 	else
 		let l1, p1, l2, p2 = Lexer.get_pos_coords p in
 		let l1, p1, l2, p2 = Lexer.get_pos_coords p in
-		let to_json l c = JObject [("line", JInt (l - 1)); ("character", JInt c)] in
+		let to_json l c = JObject [("line", JInt (l - 1)); ("character", JInt (c - 1))] in
 		JObject [
 		JObject [
 			("start", to_json l1 p1);
 			("start", to_json l1 p1);
 			("end", to_json l2 p2);
 			("end", to_json l2 p2);

+ 1 - 1
src/generators/gencommon.ml

@@ -605,7 +605,7 @@ let new_ctx con =
 		ghandle_cast = (fun to_t from_t e -> mk_cast to_t e);
 		ghandle_cast = (fun to_t from_t e -> mk_cast to_t e);
 		gon_unsafe_cast = (fun t t2 pos -> (gen.gcon.warning ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
 		gon_unsafe_cast = (fun t t2 pos -> (gen.gcon.warning ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
 		gneeds_box = (fun t -> false);
 		gneeds_box = (fun t -> false);
-		gspecial_needs_cast = (fun to_t from_t -> true);
+		gspecial_needs_cast = (fun to_t from_t -> false);
 		gsupported_conversions = Hashtbl.create 0;
 		gsupported_conversions = Hashtbl.create 0;
 
 
 		gadd_type = (fun md should_filter ->
 		gadd_type = (fun md should_filter ->

+ 37 - 18
src/generators/gencommon/castDetect.ml

@@ -45,7 +45,7 @@ open Gencommon
 		Must run before ExpressionUnwrap
 		Must run before ExpressionUnwrap
 
 
 *)
 *)
-let name = "cast_detect_2"
+let name = "cast_detect"
 let priority = solve_deps name [DBefore RealTypeParams.priority; DBefore ExpressionUnwrap.priority]
 let priority = solve_deps name [DBefore RealTypeParams.priority; DBefore ExpressionUnwrap.priority]
 
 
 (* ******************************************* *)
 (* ******************************************* *)
@@ -284,6 +284,8 @@ let do_unsafe_cast gen from_t to_t e	=
 	match gen.gfollow#run_f from_t, gen.gfollow#run_f to_t with
 	match gen.gfollow#run_f from_t, gen.gfollow#run_f to_t with
 	| TInst({ cl_kind = KTypeParameter tl },_), t2 when List.exists (fun t -> unifies t t2) tl ->
 	| TInst({ cl_kind = KTypeParameter tl },_), t2 when List.exists (fun t -> unifies t t2) tl ->
 		mk_cast to_t (mk_cast t_dynamic e)
 		mk_cast to_t (mk_cast t_dynamic e)
+	| from_t, to_t when gen.gspecial_needs_cast to_t from_t ->
+		mk_cast to_t e
 	| _ ->
 	| _ ->
 		let do_default () =
 		let do_default () =
 			gen.gon_unsafe_cast to_t e.etype e.epos;
 			gen.gon_unsafe_cast to_t e.etype e.epos;
@@ -332,6 +334,17 @@ let rec handle_cast gen e real_to_t real_from_t =
 		| TInst( { cl_path = ([], "String") }, []), _ ->
 		| TInst( { cl_path = ([], "String") }, []), _ ->
 			mk_cast false to_t e
 			mk_cast false to_t e
 		| TInst( ({ cl_path = (["cs"|"java"], "NativeArray") } as c_array), [tp_to] ), TInst({ cl_path = (["cs"|"java"], "NativeArray") }, [tp_from]) when not (type_iseq gen (gen.greal_type tp_to) (gen.greal_type tp_from)) ->
 		| TInst( ({ cl_path = (["cs"|"java"], "NativeArray") } as c_array), [tp_to] ), TInst({ cl_path = (["cs"|"java"], "NativeArray") }, [tp_from]) when not (type_iseq gen (gen.greal_type tp_to) (gen.greal_type tp_from)) ->
+				(* when running e.g. var nativeArray:NativeArray<Dynamic> = @:privateAccess someIntMap.vals, we end up with a bad cast because of the type parameters differences *)
+				(* se clean these kinds of casts *)
+				let rec clean_cast e = match e.eexpr with
+					| TCast(expr,_) -> (match gen.greal_type e.etype with
+						| TInst({ cl_path = (["cs"|"java"],"NativeArray") }, _) ->
+							clean_cast expr
+						| _ ->
+							e)
+					| TParenthesis(e) | TMeta(_,e) -> clean_cast e
+					| _ -> e
+				in
 			(* see #5751 . NativeArray is special because of its ties to Array. We could potentially deal with this for all *)
 			(* see #5751 . NativeArray is special because of its ties to Array. We could potentially deal with this for all *)
 			(* TNew expressions, but it's not that simple, since we don't want to retype the whole expression list with the *)
 			(* TNew expressions, but it's not that simple, since we don't want to retype the whole expression list with the *)
 			(* updated type. *)
 			(* updated type. *)
@@ -339,7 +352,11 @@ let rec handle_cast gen e real_to_t real_from_t =
 				| TNew(c,_,el) when c == c_array ->
 				| TNew(c,_,el) when c == c_array ->
 					mk_cast false (TInst(c_array,[tp_to])) { e with eexpr = TNew(c, [tp_to], el); etype = TInst(c_array,[tp_to]) }
 					mk_cast false (TInst(c_array,[tp_to])) { e with eexpr = TNew(c, [tp_to], el); etype = TInst(c_array,[tp_to]) }
 				| _ ->
 				| _ ->
-					mk_cast true to_t e)
+					try
+						type_eq gen EqRightDynamic tp_from tp_to;
+						e
+					with | Unify_error _ ->
+						mk_cast false to_t (clean_cast e))
 
 
 		| TInst(cl_to, params_to), TInst(cl_from, params_from) ->
 		| TInst(cl_to, params_to), TInst(cl_from, params_from) ->
 			let ret = ref None in
 			let ret = ref None in
@@ -576,26 +593,27 @@ let choose_ctor gen cl tparams etl maybe_empty_t p =
 		| Some(sup,stl) -> get_changed_stl sup (List.map (apply_params c.cl_params tl) stl)
 		| Some(sup,stl) -> get_changed_stl sup (List.map (apply_params c.cl_params tl) stl)
 	in
 	in
 	let ret_tparams = List.map (fun t -> match follow t with
 	let ret_tparams = List.map (fun t -> match follow t with
-	| TDynamic _ | TMono _ -> t_empty
-	| _ -> t) tparams in
+		| TDynamic _ | TMono _ -> t_empty
+		| _ -> t) tparams
+	in
 	let ret_stl = get_changed_stl cl ret_tparams in
 	let ret_stl = get_changed_stl cl ret_tparams in
 	let ctors = ctor :: ctor.cf_overloads in
 	let ctors = ctor :: ctor.cf_overloads in
 	List.iter replace_mono etl;
 	List.iter replace_mono etl;
 	(* first filter out or select outright maybe_empty *)
 	(* first filter out or select outright maybe_empty *)
 	let ctors, is_overload = match etl, maybe_empty_t with
 	let ctors, is_overload = match etl, maybe_empty_t with
-	| [t], Some empty_t ->
-		let count = ref 0 in
-		let is_empty_call = Type.type_iseq t empty_t in
-		let ret = List.filter (fun cf -> match follow cf.cf_type with
-		(* | TFun([_,_,t],_) -> incr count; true *)
-		| TFun([_,_,t],_) ->
-			replace_mono t; incr count; is_empty_call = (Type.type_iseq t empty_t)
-		| _ -> false) ctors in
-		ret, !count > 1
-	| _ ->
-		let len = List.length etl in
-		let ret = List.filter (fun cf -> List.length (fst (get_fun cf.cf_type)) = len) ctors in
-		ret, (match ret with | _ :: [] -> false | _ -> true)
+		| [t], Some empty_t ->
+			let count = ref 0 in
+			let is_empty_call = Type.type_iseq t empty_t in
+			let ret = List.filter (fun cf -> match follow cf.cf_type with
+				| TFun([_,_,t],_) ->
+					replace_mono t; incr count; is_empty_call = (Type.type_iseq t empty_t)
+				| _ -> false) ctors
+			in
+			ret, !count > 1
+		| _ ->
+			let len = List.length etl in
+			let ret = List.filter (fun cf -> List.length (fst (get_fun cf.cf_type)) = len) ctors in
+			ret, (match ret with | _ :: [] -> false | _ -> true)
 	in
 	in
 	let rec check_arg arglist elist =
 	let rec check_arg arglist elist =
 		match arglist, elist with
 		match arglist, elist with
@@ -1192,9 +1210,10 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 						| (TInst(c,tl) as tinst1), TAbstract({ a_path = ["cs"],"Pointer" }, [tinst2]) when type_iseq gen tinst1 (gen.greal_type tinst2) ->
 						| (TInst(c,tl) as tinst1), TAbstract({ a_path = ["cs"],"Pointer" }, [tinst2]) when type_iseq gen tinst1 (gen.greal_type tinst2) ->
 							run expr
 							run expr
 						| _ ->
 						| _ ->
+							let expr = run expr in
 							let last_unsafe = gen.gon_unsafe_cast in
 							let last_unsafe = gen.gon_unsafe_cast in
 							gen.gon_unsafe_cast <- (fun t t2 pos -> ());
 							gen.gon_unsafe_cast <- (fun t t2 pos -> ());
-							let ret = handle (run expr) e.etype expr.etype in
+							let ret = handle expr e.etype expr.etype in
 							gen.gon_unsafe_cast <- last_unsafe;
 							gen.gon_unsafe_cast <- last_unsafe;
 							match ret.eexpr with
 							match ret.eexpr with
 								| TCast _ -> { ret with etype = gen.greal_type e.etype }
 								| TCast _ -> { ret with etype = gen.greal_type e.etype }

+ 24 - 6
src/generators/gencommon/dynamicFieldAccess.ml

@@ -56,10 +56,28 @@ let priority = solve_deps name [DAfter DynamicOperators.priority]
 	change_expr (expr) (field_access_expr) (field) (setting expr) (is_unsafe) : changes the expression
 	change_expr (expr) (field_access_expr) (field) (setting expr) (is_unsafe) : changes the expression
 	call_expr (expr) (field_access_expr) (field) (call_params) : changes a call expression
 	call_expr (expr) (field_access_expr) (field) (call_params) : changes a call expression
 *)
 *)
-let configure gen (is_dynamic:texpr->texpr->Type.tfield_access->bool) (change_expr:texpr->texpr->string->texpr option->bool->texpr) (call_expr:texpr->texpr->string->texpr list->texpr) =
+let configure gen ?fix_tparam_access (is_dynamic:texpr->Type.tfield_access->bool) (change_expr:texpr->texpr->string->texpr option->bool->texpr) (call_expr:texpr->texpr->string->texpr list->texpr) =
+	let fix_tparam_access = match fix_tparam_access with
+		| None -> false
+		| Some f -> f
+	in
+	let is_nondynamic_tparam fexpr f = match follow fexpr.etype with
+		| TInst({ cl_kind = KTypeParameter(tl) }, _) ->
+			List.exists (fun t -> not (is_dynamic { fexpr with etype = t } f)) tl
+		| _ -> false
+	in
+
+	let fix_tparam_access = true in
 	let rec run e =
 	let rec run e =
 		match e.eexpr with
 		match e.eexpr with
 		(* class types *)
 		(* class types *)
+		| TField(fexpr, f) when fix_tparam_access && is_nondynamic_tparam fexpr f ->
+			(match follow fexpr.etype with
+				| TInst({ cl_kind = KTypeParameter(tl) }, _) ->
+					let t = List.find (fun t -> not (is_dynamic { fexpr with etype = t } f)) tl in
+					{ e with eexpr = TField(mk_cast t (run fexpr), f) }
+				| _ -> assert false)
+
 		| TField(fexpr, f) when is_some (anon_class fexpr.etype) ->
 		| TField(fexpr, f) when is_some (anon_class fexpr.etype) ->
 			let decl = get (anon_class fexpr.etype) in
 			let decl = get (anon_class fexpr.etype) in
 			let name = field_name f in
 			let name = field_name f in
@@ -81,7 +99,7 @@ let configure gen (is_dynamic:texpr->texpr->Type.tfield_access->bool) (change_ex
 				| _ ->
 				| _ ->
 					change_expr e { fexpr with eexpr = TTypeExpr decl } (field_name f) None true)
 					change_expr e { fexpr with eexpr = TTypeExpr decl } (field_name f) None true)
 
 
-		| TField (fexpr, f) when is_dynamic e fexpr f ->
+		| TField (fexpr, f) when is_dynamic fexpr f ->
 			change_expr e (run fexpr) (field_name f) None true
 			change_expr e (run fexpr) (field_name f) None true
 
 
 		| TCall ({ eexpr = TField (_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "field" })) }, [obj; { eexpr = TConst (TString field) }]) ->
 		| TCall ({ eexpr = TField (_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "field" })) }, [obj; { eexpr = TConst (TString field) }]) ->
@@ -94,7 +112,7 @@ let configure gen (is_dynamic:texpr->texpr->Type.tfield_access->bool) (change_ex
 		| TCall ({ eexpr = TField (_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "setField" } )) }, [obj; { eexpr = TConst(TString field) }; evalue]) ->
 		| TCall ({ eexpr = TField (_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "setField" } )) }, [obj; { eexpr = TConst(TString field) }; evalue]) ->
 			change_expr (mk_field_access gen obj field obj.epos) (run obj) field (Some (run evalue)) false
 			change_expr (mk_field_access gen obj field obj.epos) (run obj) field (Some (run evalue)) false
 
 
-		| TBinop (OpAssign, { eexpr = TField(fexpr, f) }, evalue) when is_dynamic e fexpr f ->
+		| TBinop (OpAssign, { eexpr = TField(fexpr, f) }, evalue) when is_dynamic fexpr f ->
 			change_expr e (run fexpr) (field_name f) (Some (run evalue)) true
 			change_expr e (run fexpr) (field_name f) (Some (run evalue)) true
 
 
 		| TBinop (OpAssign, { eexpr = TField(fexpr, f) }, evalue) ->
 		| TBinop (OpAssign, { eexpr = TField(fexpr, f) }, evalue) ->
@@ -104,13 +122,13 @@ let configure gen (is_dynamic:texpr->texpr->Type.tfield_access->bool) (change_ex
 			| _ ->
 			| _ ->
 				Type.map_expr run e)
 				Type.map_expr run e)
 
 
-		| TBinop (OpAssignOp _, { eexpr = TField (fexpr, f) }, _) when is_dynamic e fexpr f ->
+		| TBinop (OpAssignOp _, { eexpr = TField (fexpr, f) }, _) when is_dynamic fexpr f ->
 			assert false (* this case shouldn't happen *)
 			assert false (* this case shouldn't happen *)
 		| TUnop (Increment, _, { eexpr = TField (({ eexpr = TLocal _ } as fexpr), f)})
 		| TUnop (Increment, _, { eexpr = TField (({ eexpr = TLocal _ } as fexpr), f)})
-		| TUnop (Decrement, _, { eexpr = TField (({ eexpr = TLocal _ } as fexpr), f)}) when is_dynamic e fexpr f ->
+		| TUnop (Decrement, _, { eexpr = TField (({ eexpr = TLocal _ } as fexpr), f)}) when is_dynamic fexpr f ->
 			assert false (* this case shouldn't happen *)
 			assert false (* this case shouldn't happen *)
 
 
-		| TCall ({ eexpr = TField (fexpr, f) }, params) when is_dynamic e fexpr f ->
+		| TCall ({ eexpr = TField (fexpr, f) }, params) when is_dynamic fexpr f && (not (fix_tparam_access && is_nondynamic_tparam fexpr f)) ->
 			call_expr e (run fexpr) (field_name f) (List.map run params)
 			call_expr e (run fexpr) (field_name f) (List.map run params)
 
 
 		| _ ->
 		| _ ->

+ 2 - 3
src/generators/gencommon/dynamicOperators.ml

@@ -62,7 +62,7 @@ open Gencommon
 		must run before OverloadingConstructor due to later priority conflicts. Since ExpressionUnwrap is only
 		must run before OverloadingConstructor due to later priority conflicts. Since ExpressionUnwrap is only
 		defined afterwards, we will set this value with absolute values
 		defined afterwards, we will set this value with absolute values
 *)
 *)
-let init com handle_strings (should_change:texpr->bool) (equals_handler:texpr->texpr->texpr) (dyn_plus_handler:texpr->texpr->texpr->texpr) (compare_handler:texpr->texpr->texpr) =
+let init com handle_strings (should_change:texpr->bool) (equals_handler:texpr->texpr->texpr) (dyn_plus_handler:texpr->texpr->texpr->texpr) (compare_handler:Ast.binop->texpr->texpr->texpr->texpr) =
 	let get_etype_one e =
 	let get_etype_one e =
 		if like_int e.etype then
 		if like_int e.etype then
 			ExprBuilder.make_int com 1 e.epos
 			ExprBuilder.make_int com 1 e.epos
@@ -110,8 +110,7 @@ let init com handle_strings (should_change:texpr->bool) (equals_handler:texpr->t
 				else
 				else
 					dyn_plus_handler e (run e1) (run e2)
 					dyn_plus_handler e (run e1) (run e2)
 			| OpGt | OpGte | OpLt | OpLte  -> (* type 2 *)
 			| OpGt | OpGte | OpLt | OpLte  -> (* type 2 *)
-				let zero = ExprBuilder.make_int com 0 e.epos in
-				mk (TBinop (op, compare_handler (run e1) (run e2), zero)) com.basic.tbool e.epos
+				compare_handler op e (run e1) (run e2)
 			| OpMult | OpDiv | OpSub | OpMod -> (* always cast everything to double *)
 			| OpMult | OpDiv | OpSub | OpMod -> (* always cast everything to double *)
 				let etype = (get_etype_one e).etype in
 				let etype = (get_etype_one e).etype in
 				{ e with eexpr = TBinop (op, mk_cast etype (run e1), mk_cast etype (run e2)) }
 				{ e with eexpr = TBinop (op, mk_cast etype (run e1), mk_cast etype (run e2)) }

+ 2 - 2
src/generators/gencommon/reflectionCFs.ml

@@ -1594,7 +1594,7 @@ let get_closure_func ctx closure_cl =
 
 
 let configure_dynamic_field_access ctx =
 let configure_dynamic_field_access ctx =
 	let gen = ctx.rcf_gen in
 	let gen = ctx.rcf_gen in
-	let is_dynamic expr fexpr field =
+	let is_dynamic fexpr field =
 		match (field_access_esp gen (gen.greal_type fexpr.etype) field) with
 		match (field_access_esp gen (gen.greal_type fexpr.etype) field) with
 		| FEnumField _
 		| FEnumField _
 		| FClassField _ -> false
 		| FClassField _ -> false
@@ -1602,7 +1602,7 @@ let configure_dynamic_field_access ctx =
 	in
 	in
 
 
 	let maybe_hash = if ctx.rcf_optimize then fun str pos -> Some (hash_field_i32 ctx pos str) else fun str pos -> None in
 	let maybe_hash = if ctx.rcf_optimize then fun str pos -> Some (hash_field_i32 ctx pos str) else fun str pos -> None in
-	DynamicFieldAccess.configure gen is_dynamic
+	DynamicFieldAccess.configure gen ~fix_tparam_access:true is_dynamic
 		(fun expr fexpr field set is_unsafe ->
 		(fun expr fexpr field set is_unsafe ->
 			let hash = maybe_hash field fexpr.epos in
 			let hash = maybe_hash field fexpr.epos in
 			ctx.rcf_on_getset_field expr fexpr field hash set is_unsafe
 			ctx.rcf_on_getset_field expr fexpr field hash set is_unsafe

+ 5 - 2
src/generators/gencommon/setHXGen.ml

@@ -45,13 +45,16 @@ let run_filter com types =
 					else
 					else
 						Option.map_default (is_hxgen_class) false c.cl_super || List.exists is_hxgen_class c.cl_implements
 						Option.map_default (is_hxgen_class) false c.cl_super || List.exists is_hxgen_class c.cl_implements
 				end else begin
 				end else begin
-					if Meta.has Meta.NativeChildren c.cl_meta || Meta.has Meta.NativeGen c.cl_meta then
+					if Meta.has Meta.NativeChildren c.cl_meta || Meta.has Meta.NativeGen c.cl_meta || Meta.has Meta.Struct c.cl_meta then
 						Option.map_default is_hxgen_class false c.cl_super || List.exists is_hxgen_class c.cl_implements
 						Option.map_default is_hxgen_class false c.cl_super || List.exists is_hxgen_class c.cl_implements
 					else
 					else
 						let rec has_nativec (c,p) =
 						let rec has_nativec (c,p) =
 							if is_hxgen_class (c,p) then
 							if is_hxgen_class (c,p) then
 								false
 								false
-							else
+							else if Meta.has Meta.Struct c.cl_meta then begin
+								com.error ("Struct types cannot be subclassed") c.cl_pos;
+								true
+							end else
 								(Meta.has Meta.NativeChildren c.cl_meta && not (Option.map_default is_hxgen_class false c.cl_super || List.exists is_hxgen_class c.cl_implements))
 								(Meta.has Meta.NativeChildren c.cl_meta && not (Option.map_default is_hxgen_class false c.cl_super || List.exists is_hxgen_class c.cl_implements))
 								|| Option.map_default has_nativec false c.cl_super
 								|| Option.map_default has_nativec false c.cl_super
 						in
 						in

+ 45 - 8
src/generators/gencs.ml

@@ -2045,6 +2045,25 @@ let generate con =
 						gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf
 						gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf
 					) cf.cf_overloads
 					) cf.cf_overloads
 				| Var _ | Method MethDynamic -> ()
 				| Var _ | Method MethDynamic -> ()
+				| Method _ when is_new && Meta.has Meta.Struct cl.cl_meta && fst (get_fun cf.cf_type) = [] ->
+						(* make sure that the method is empty *)
+						let rec check_empty expr = match expr.eexpr with
+							| TBlock(bl) -> bl = [] || List.for_all check_empty bl
+							| TMeta(_,e) -> check_empty e
+							| TParenthesis(e) -> check_empty e
+							| TConst(TNull) -> true
+							| TFunction(tf) -> check_empty tf.tf_expr
+							| _ -> false
+						in
+						(match cf.cf_expr with
+							| Some e ->
+								if not (check_empty e) then
+									gen.gcon.error "The body of a zero argument constructor of a struct should be empty" e.epos
+							| _ -> ());
+						List.iter (fun cf ->
+							if cl.cl_interface || cf.cf_expr <> None then
+								gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf
+						) cf.cf_overloads;
 				| Method mkind ->
 				| Method mkind ->
 					List.iter (fun cf ->
 					List.iter (fun cf ->
 						if cl.cl_interface || cf.cf_expr <> None then
 						if cl.cl_interface || cf.cf_expr <> None then
@@ -2972,6 +2991,14 @@ let generate con =
 			| _ -> false
 			| _ -> false
 		in
 		in
 
 
+		let nullable_basic t = match gen.gfollow#run_f t with
+			| TType({ t_path = ([],"Null") }, [t])
+			| TAbstract({ a_path = ([],"Null") }, [t]) when is_cs_basic_type t ->
+				Some(t)
+			| _ ->
+				None
+		in
+
 		DynamicOperators.configure gen
 		DynamicOperators.configure gen
 			~handle_strings:false
 			~handle_strings:false
 			(fun e -> match e.eexpr with
 			(fun e -> match e.eexpr with
@@ -2995,7 +3022,7 @@ let generate con =
 				| TBinop (Ast.OpLt, e1, e2)
 				| TBinop (Ast.OpLt, e1, e2)
 				| TBinop (Ast.OpLte, e1, e2)
 				| TBinop (Ast.OpLte, e1, e2)
 				| TBinop (Ast.OpGte, e1, e2)
 				| TBinop (Ast.OpGte, e1, e2)
-				| TBinop (Ast.OpGt, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 || is_string e1.etype || is_string e2.etype
+				| TBinop (Ast.OpGt, e1, e2) -> is_dynamic e.etype || is_dynamic e1.etype || is_dynamic e2.etype || is_string e1.etype || is_string e2.etype
 				| TBinop (_, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2
 				| TBinop (_, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2
 				| TUnop (_, _, e1) -> is_dynamic_expr e1 || is_null_expr e1 (* we will see if the expression is Null<T> also, as the unwrap from Unop will be the same *)
 				| TUnop (_, _, e1) -> is_dynamic_expr e1 || is_null_expr e1 (* we will see if the expression is Null<T> also, as the unwrap from Unop will be the same *)
 				| _ -> false)
 				| _ -> false)
@@ -3037,13 +3064,23 @@ let generate con =
 					| _ ->
 					| _ ->
 						let static = mk_static_field_access_infer (runtime_cl) "plus"  e1.epos [] in
 						let static = mk_static_field_access_infer (runtime_cl) "plus"  e1.epos [] in
 						mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos })
 						mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos })
-			(fun e1 e2 ->
-				if is_string e1.etype then begin
-					{ e1 with eexpr = TCall(mk_static_field_access_infer string_cl "Compare" e1.epos [], [ e1; e2 ]); etype = gen.gcon.basic.tint }
-				end else begin
-					let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in
-					{ eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos }
-				end);
+		(fun op e e1 e2 ->
+				match nullable_basic e1.etype, nullable_basic e2.etype with
+					| Some(t1), None when is_cs_basic_type e2.etype ->
+						{ e with eexpr = TBinop(op, mk_cast t1 e1, e2) }
+					| None, Some(t2) when is_cs_basic_type e1.etype ->
+						{ e with eexpr = TBinop(op, e1, mk_cast t2 e2) }
+					| _ ->
+							let handler = if is_string e1.etype then begin
+									{ e1 with eexpr = TCall(mk_static_field_access_infer string_cl "Compare" e1.epos [], [ e1; e2 ]); etype = gen.gcon.basic.tint }
+								end else begin
+									let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in
+									{ eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos }
+								end
+							in
+							let zero = ExprBuilder.make_int gen.gcon 0 e.epos in
+							{ e with eexpr = TBinop(op, handler, zero) }
+		);
 
 
 		FilterClosures.configure gen (fun e1 s -> true) (ReflectionCFs.get_closure_func rcf_ctx closure_cl);
 		FilterClosures.configure gen (fun e1 s -> true) (ReflectionCFs.get_closure_func rcf_ctx closure_cl);
 
 

+ 279 - 68
src/generators/genjava.ml

@@ -37,32 +37,72 @@ let is_boxed_type t = match follow t with
 	| TInst ({ cl_path = (["java";"lang"], "Byte") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Byte") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Short") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Short") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Character") }, [])
 	| TInst ({ cl_path = (["java";"lang"], "Character") }, [])
-	| TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> true
-	| TAbstract ({ a_path = (["java";"lang"], "Boolean") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Double") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Integer") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Byte") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Short") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Character") }, [])
-	| TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> true
+	| TInst ({ cl_path = (["java";"lang"], "Float") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Long") }, []) -> true
 	| _ -> false
 	| _ -> false
 
 
-let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with
-	| TInst ({ cl_path = (["java";"lang"], "Boolean") }, []) -> gen.gcon.basic.tbool
-	| TInst ({ cl_path = (["java";"lang"], "Double") }, []) -> gen.gcon.basic.tfloat
-	| TInst ({ cl_path = (["java";"lang"], "Integer") }, []) -> gen.gcon.basic.tint
-	| TInst ({ cl_path = (["java";"lang"], "Byte") }, []) -> tbyte
-	| TInst ({ cl_path = (["java";"lang"], "Short") }, []) -> tshort
-	| TInst ({ cl_path = (["java";"lang"], "Character") }, []) -> tchar
-	| TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> tfloat
-	| TAbstract ({ a_path = (["java";"lang"], "Boolean") }, []) -> gen.gcon.basic.tbool
-	| TAbstract ({ a_path = (["java";"lang"], "Double") }, []) -> gen.gcon.basic.tfloat
-	| TAbstract ({ a_path = (["java";"lang"], "Integer") }, []) -> gen.gcon.basic.tint
-	| TAbstract ({ a_path = (["java";"lang"], "Byte") }, []) -> tbyte
-	| TAbstract ({ a_path = (["java";"lang"], "Short") }, []) -> tshort
-	| TAbstract ({ a_path = (["java";"lang"], "Character") }, []) -> tchar
-	| TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> tfloat
-	| _ -> assert false
+let is_boxed_of_t boxed_t orig_t = match follow boxed_t, follow orig_t with
+	| TInst ({ cl_path = (["java";"lang"], "Boolean") }, []),
+	  TAbstract({ a_path = ([],"Bool") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Double") }, []),
+	  TAbstract({ a_path = ([],"Float") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Integer") }, []),
+	  TAbstract({ a_path = ([],"Int") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Byte") }, []),
+	  TAbstract({ a_path = (["java"],"Int8") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Short") }, []),
+	  TAbstract({ a_path = (["java"],"Int16") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Character") }, []),
+	  TAbstract({ a_path = (["java"],"Char16") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Float") }, []),
+	  TAbstract({ a_path = ([],"Single") }, [])
+	| TInst ({ cl_path = (["java";"lang"], "Long") }, []),
+	  TAbstract({ a_path = (["java"],"Int64") }, []) ->
+		true
+	| _ -> false
+
+let is_boxed_int_type boxed_t = match follow boxed_t with
+	| TInst ({ cl_path = (["java";"lang"], ("Integer"|"Byte"|"Short"|"Long")) }, []) ->
+		true
+	| _ -> false
+
+let is_int64_type t = match follow t with
+	| TAbstract ({ a_path = (["java"], ("Int64")) }, []) ->
+		true
+	| _ -> false
+
+let is_boxed_int64_type t = match follow t with
+	| TInst ({ cl_path = (["java";"lang"], ("Long")) }, []) ->
+		true
+	| _ -> false
+
+let is_int_type t = match follow t with
+	| TAbstract ({ a_path = ([], ("Int")) }, [])
+	| TAbstract ({ a_path = (["java"], ("Int8" | "Int16" | "Int64")) }, []) ->
+		true
+	| _ -> false
+
+let is_boxed_float_type boxed_t = match follow boxed_t with
+	| TInst ({ cl_path = (["java";"lang"], ("Double"|"Float")) }, []) ->
+		true
+	| _ -> false
+
+let is_float_type t = match follow t with
+	| TAbstract ({ a_path = ([], ("Float"|"Single")) }, []) ->
+		true
+	| _ -> false
+
+let is_boxed_number t = match follow t with
+	| TInst ({ cl_path = (["java";"lang"], ("Float"|"Double"|"Integer"|"Byte"|"Short"|"Long")) }, []) ->
+		true
+	| _ ->
+		false
+
+let is_unboxed_number t = match follow t with
+	| TAbstract ({ a_path = ([], ("Float"|"Single"|"Int")) }, [])
+	| TAbstract ({ a_path = (["java"], ("Int8" | "Int16" | "Int64")) }, []) ->
+		true
+	| _ -> false
 
 
 let rec t_has_type_param t = match follow t with
 let rec t_has_type_param t = match follow t with
 	| TInst({ cl_kind = KTypeParameter _ }, []) -> true
 	| TInst({ cl_kind = KTypeParameter _ }, []) -> true
@@ -96,15 +136,17 @@ let rec replace_type_param t = match follow t with
 	| TInst(cl, params) -> TInst(cl, List.map replace_type_param params)
 	| TInst(cl, params) -> TInst(cl, List.map replace_type_param params)
 	| _ -> t
 	| _ -> t
 
 
+let in_runtime_class gen =
+	match gen.gcurrent_class with
+	| Some { cl_path = ["haxe";"lang"],"Runtime"} -> true
+	| _ -> false
+
 let is_java_basic_type t =
 let is_java_basic_type t =
 	match follow t with
 	match follow t with
 		| TInst( { cl_path = (["haxe"], "Int32") }, [] )
 		| TInst( { cl_path = (["haxe"], "Int32") }, [] )
 		| TInst( { cl_path = (["haxe"], "Int64") }, [] )
 		| TInst( { cl_path = (["haxe"], "Int64") }, [] )
-		| TAbstract( { a_path = ([], "Single") }, [] )
 		| TAbstract( { a_path = (["java"], ("Int8" | "Int16" | "Char16" | "Int64")) }, [] )
 		| TAbstract( { a_path = (["java"], ("Int8" | "Int16" | "Char16" | "Int64")) }, [] )
-		| TAbstract( { a_path =	([], "Int") }, [] )
-		| TAbstract( { a_path =	([], "Float") }, [] )
-		| TAbstract( { a_path =	([], "Bool") }, [] ) ->
+		| TAbstract( { a_path =	([], ("Int"|"Float"|"Bool"|"Single")) }, [] ) ->
 			true
 			true
 		| _ -> false
 		| _ -> false
 
 
@@ -150,6 +192,12 @@ let is_cl t = match follow t with
 	| TAnon(a) when is_some (anon_class t) -> true
 	| TAnon(a) when is_some (anon_class t) -> true
 	| _ -> false
 	| _ -> false
 
 
+let mk_cast_if_needed t_to e =
+	if type_iseq t_to e.etype then
+		e
+	else
+		mk_cast t_to e
+
 
 
 (* ******************************************* *)
 (* ******************************************* *)
 (* JavaSpecificESynf *)
 (* JavaSpecificESynf *)
@@ -338,7 +386,11 @@ struct
 			| final :: [] -> is_final_return_expr is_switch final
 			| final :: [] -> is_final_return_expr is_switch final
 			| hd :: tl -> is_final_return_block is_switch tl
 			| hd :: tl -> is_final_return_block is_switch tl
 
 
-	let is_null e = match e.eexpr with | TConst(TNull) -> true | _ -> false
+	let rec is_null e = match e.eexpr with
+		| TConst(TNull) -> true
+		| TParenthesis(e)
+		| TMeta(_,e) -> is_null e
+		| _ -> false
 
 
 	let rec is_equatable gen t =
 	let rec is_equatable gen t =
 		match follow t with
 		match follow t with
@@ -549,16 +601,104 @@ struct
 		| _ -> assert false
 		| _ -> assert false
 
 
 	let configure gen runtime_cl =
 	let configure gen runtime_cl =
+		let cl_boolean = get_cl (get_type gen (["java";"lang"],"Boolean")) in
+		let cl_number = get_cl (get_type gen (["java";"lang"],"Number")) in
+
 		(if java_hash "Testing string hashCode implementation from haXe" <> (Int32.of_int 545883604) then assert false);
 		(if java_hash "Testing string hashCode implementation from haXe" <> (Int32.of_int 545883604) then assert false);
 		let basic = gen.gcon.basic in
 		let basic = gen.gcon.basic in
-		(* let tchar = mt_to_t_dyn ( get_type gen (["java"], "Char16") ) in *)
-		(* let tbyte = mt_to_t_dyn ( get_type gen (["java"], "Int8") ) in *)
-		(* let tshort = mt_to_t_dyn ( get_type gen (["java"], "Int16") ) in *)
-		(* let tsingle = mt_to_t_dyn ( get_type gen ([], "Single") ) in *)
+		let tbyte = mt_to_t_dyn ( get_type gen (["java"], "Int8") ) in
+		let tshort = mt_to_t_dyn ( get_type gen (["java"], "Int16") ) in
+		let tsingle = mt_to_t_dyn ( get_type gen ([], "Single") ) in
 		let ti64 = mt_to_t_dyn ( get_type gen (["java"], "Int64") ) in
 		let ti64 = mt_to_t_dyn ( get_type gen (["java"], "Int64") ) in
 		let string_ext = get_cl ( get_type gen (["haxe";"lang"], "StringExt")) in
 		let string_ext = get_cl ( get_type gen (["haxe";"lang"], "StringExt")) in
 		let fast_cast = Common.defined gen.gcon Define.FastCast in
 		let fast_cast = Common.defined gen.gcon Define.FastCast in
 
 
+		let get_unboxed_from_boxed boxed_t =
+			match boxed_t with
+				| TInst( ({ cl_path = (["java";"lang"],name) } as cl), [] ) -> (match name with
+					| "Double" ->
+						cl, basic.tfloat
+					| "Integer" ->
+						cl, basic.tint
+					| "Byte" ->
+						cl, tbyte
+					| "Short" ->
+						cl, tshort
+					| "Float" ->
+						cl, tsingle
+					| "Long" ->
+						cl, ti64
+					| _ ->
+						assert false)
+				| _ -> assert false
+		in
+
+		let mk_valueof_call boxed_t expr =
+			let box_cl, unboxed_t = get_unboxed_from_boxed boxed_t in
+			let fn = TFun(["param1",false,unboxed_t],boxed_t) in
+			{
+				eexpr = TCall(mk_static_field_access box_cl "valueOf" fn expr.epos, [mk_cast_if_needed unboxed_t expr]);
+				etype = boxed_t;
+				epos = expr.epos;
+			}
+		in
+
+		let mk_unbox unboxed_t boxed_e =
+			if is_int64_type unboxed_t then
+				{
+					eexpr = TCall(
+						mk_static_field_access_infer runtime_cl "getInt64FromNumber" boxed_e.epos [],
+						[ boxed_e ]
+					);
+					etype = ti64;
+					epos = boxed_e.epos
+				}
+			else if is_int_type unboxed_t then
+				mk_cast_if_needed unboxed_t {
+					eexpr = TCall(
+						mk_static_field_access_infer runtime_cl "getIntFromNumber" boxed_e.epos [],
+						[ boxed_e ]
+					);
+					etype = basic.tint;
+					epos = boxed_e.epos
+				}
+			else
+				mk_cast_if_needed unboxed_t {
+					eexpr = TCall(
+						mk_static_field_access_infer runtime_cl "getFloatFromNumber" boxed_e.epos [],
+						[ boxed_e ]
+					);
+					etype = basic.tfloat;
+					epos = boxed_e.epos
+				}
+		in
+
+		let mk_dyn_box boxed_t expr =
+			let name = match boxed_t with
+				| TInst({ cl_path = (["java";"lang"],"Integer") },[]) ->
+					"numToInteger"
+				| TInst({ cl_path = (["java";"lang"],"Double") },[]) ->
+					"numToDouble"
+				| TInst({ cl_path = (["java";"lang"],"Float") },[]) ->
+					"numToFloat"
+				| TInst({ cl_path = (["java";"lang"],"Byte") },[]) ->
+					"numToByte"
+				| TInst({ cl_path = (["java";"lang"],"Long") },[]) ->
+					"numToLong"
+				| TInst({ cl_path = (["java";"lang"],"Short") },[]) ->
+					"numToShort"
+				| _ -> gen.gcon.error ("Invalid boxed type " ^ (debug_type boxed_t)) expr.epos; assert false
+			in
+			{
+				eexpr = TCall(
+					mk_static_field_access_infer runtime_cl name expr.epos [],
+					[ mk_cast (TInst(cl_number,[])) expr ]
+				);
+				etype = boxed_t;
+				epos = expr.epos
+			}
+		in
+
 		let rec run e =
 		let rec run e =
 			match e.eexpr with
 			match e.eexpr with
 				(* for new NativeArray<T> issues *)
 				(* for new NativeArray<T> issues *)
@@ -589,18 +729,40 @@ struct
 						| _ ->
 						| _ ->
 							{ e with eexpr = TCall(run efield, List.map run args) }
 							{ e with eexpr = TCall(run efield, List.map run args) }
 					)
 					)
-(*				 | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, { cf_name = ("toString") })) }, [] ) ->
-					run ef *)
 
 
-				(* | TCast(expr, m) when is_boxed_type e.etype -> *)
-				(* 	(* let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with *) *)
-				(* 	run { e with etype = unboxed_type gen e.etype tbyte tshort tchar tsingle } *)
+				| TCast(expr, _) when is_boxed_number (gen.greal_type expr.etype) && is_unboxed_number (gen.greal_type e.etype) ->
+					let to_t = gen.greal_type e.etype in
+					mk_unbox to_t (run expr)
+
+				| TCast(expr, md) when is_boxed_number (gen.greal_type e.etype) ->
+					let to_t = gen.greal_type e.etype in
+					let from_t = gen.greal_type expr.etype in
+					let ret = if is_unboxed_number from_t then
+							mk_valueof_call to_t (run expr)
+						else if is_boxed_number from_t then
+							if type_iseq from_t to_t then begin
+								(* special case for when the expression is null, as we sometimes need to give *)
+								(* a little help to Java's typer *)
+								if is_null expr then
+									{ e with eexpr = TCast(run expr, md) }
+								else
+									run expr
+							end else
+								mk_dyn_box (gen.greal_type e.etype) (run expr)
+						else begin
+							if in_runtime_class gen then
+								mk_cast e.etype (run expr)
+							else
+								mk_dyn_box (gen.greal_type e.etype) (run expr)
+						end
+					in
+					ret
 
 
-				| TCast(expr, _) when is_bool e.etype && is_dynamic gen expr.etype ->
+				| TCast(expr, _) when is_bool e.etype ->
 					{
 					{
 						eexpr = TCall(
 						eexpr = TCall(
 							mk_static_field_access_infer runtime_cl "toBool" expr.epos [],
 							mk_static_field_access_infer runtime_cl "toBool" expr.epos [],
-							[ run expr ]
+							[ mk_cast_if_needed (TInst(cl_boolean,[])) (run expr) ]
 						);
 						);
 						etype = basic.tbool;
 						etype = basic.tbool;
 						epos = e.epos
 						epos = e.epos
@@ -625,14 +787,6 @@ struct
 
 
 					if needs_cast then mk_cast e.etype ret else ret
 					if needs_cast then mk_cast e.etype ret else ret
 
 
-				(*| TCast(expr, c) when is_int_float gen e.etype ->
-					(* cases when float x = (float) (java.lang.Double val); *)
-					(* FIXME: this fix is broken since it will fail on cases where float x = (float) (java.lang.Float val) or similar. FIX THIS *)
-					let need_second_cast = match gen.gfollow#run_f e.etype with
-						| TInst _ -> false
-						| _ -> true
-					in
-					if need_second_cast then { e with eexpr = TCast(mk_cast (follow e.etype) (run expr), c) }  else Type.map_expr run e*)
 				| TCast(expr, _) when like_i64 e.etype && is_dynamic gen expr.etype ->
 				| TCast(expr, _) when like_i64 e.etype && is_dynamic gen expr.etype ->
 					{
 					{
 						eexpr = TCall(
 						eexpr = TCall(
@@ -948,6 +1102,15 @@ let generate con =
 
 
 	let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in
 	let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in
 
 
+	let cl_boolean = get_cl (get_type gen (["java";"lang"],"Boolean")) in
+	let cl_double = get_cl (get_type gen (["java";"lang"],"Double")) in
+	let cl_integer = get_cl (get_type gen (["java";"lang"],"Integer")) in
+	let cl_byte = get_cl (get_type gen (["java";"lang"],"Byte")) in
+	let cl_short = get_cl (get_type gen (["java";"lang"],"Short")) in
+	let cl_character = get_cl (get_type gen (["java";"lang"],"Character")) in
+	let cl_float = get_cl (get_type gen (["java";"lang"],"Float")) in
+	let cl_long = get_cl (get_type gen (["java";"lang"],"Long")) in
+
 	let rec real_type t =
 	let rec real_type t =
 		let t = gen.gfollow#run_f t in
 		let t = gen.gfollow#run_f t in
 		match t with
 		match t with
@@ -964,14 +1127,31 @@ let generate con =
 				TInst(c, List.map (fun _ -> t_dynamic) params)
 				TInst(c, List.map (fun _ -> t_dynamic) params)
 			| TInst({ cl_kind = KExpr _ }, _) -> t_dynamic
 			| TInst({ cl_kind = KExpr _ }, _) -> t_dynamic
 			| TInst _ -> t
 			| TInst _ -> t
-			| TType({ t_path = ([], "Null") }, [t]) when is_java_basic_type (gen.gfollow#run_f t) -> t_dynamic
-			| TType({ t_path = ([], "Null") }, [t]) ->
-				(match follow t with
+			| TType({ t_path = ([], "Null") }, [t]) -> (
+				match gen.gfollow#run_f t with
+				| TAbstract( { a_path = ([], "Bool") }, [] ) ->
+					TInst(cl_boolean, [])
+				| TAbstract( { a_path = ([], "Float") }, [] ) ->
+					TInst(cl_double, [])
+				| TAbstract( { a_path = ([], "Int") }, [] ) ->
+					TInst(cl_integer, [])
+				| TAbstract( { a_path = (["java"], "Int8") }, [] ) ->
+					TInst(cl_byte, [])
+				| TAbstract( { a_path = (["java"], "Int16") }, [] ) ->
+					TInst(cl_short, [])
+				| TAbstract( { a_path = (["java"], "Char16") }, [] ) ->
+					TInst(cl_character, [])
+				| TAbstract( { a_path = ([], "Single") }, [] ) ->
+					TInst(cl_float, [])
+				| TAbstract( { a_path = (["java"], "Int64") }, [] )
+				| TAbstract( { a_path = (["haxe"], "Int64") }, [] ) ->
+					TInst(cl_long, [])
+				| _ -> (match follow t with
 					| TInst( { cl_kind = KTypeParameter _ }, []) ->
 					| TInst( { cl_kind = KTypeParameter _ }, []) ->
 							t_dynamic
 							t_dynamic
-							(* real_type t *)
 					| _ -> real_type t
 					| _ -> real_type t
 				)
 				)
+			)
 			| TType _ | TAbstract _ -> t
 			| TType _ | TAbstract _ -> t
 			| TAnon (anon) -> (match !(anon.a_status) with
 			| TAnon (anon) -> (match !(anon.a_status) with
 				| Statics _ | EnumStatics _ | AbstractStatics _ -> t
 				| Statics _ | EnumStatics _ | AbstractStatics _ -> t
@@ -2059,6 +2239,14 @@ let generate con =
 
 
 	gen.greal_type <- real_type;
 	gen.greal_type <- real_type;
 	gen.greal_type_param <- change_param_type;
 	gen.greal_type_param <- change_param_type;
+	gen.gspecial_needs_cast <- (fun to_t from_t ->
+		is_boxed_of_t to_t from_t ||
+		is_boxed_of_t from_t to_t ||
+		( (is_boxed_int_type from_t || is_boxed_float_type from_t ) &&
+		  (is_boxed_int_type to_t || is_boxed_float_type to_t || is_int_type to_t || is_float_type to_t) ) ||
+		( (is_boxed_int_type to_t || is_boxed_float_type to_t ) &&
+			(is_boxed_int_type from_t || is_boxed_float_type from_t || is_int_type from_t || is_float_type from_t) )
+	);
 
 
 	(* before running the filters, follow all possible types *)
 	(* before running the filters, follow all possible types *)
 	(* this is needed so our module transformations don't break some core features *)
 	(* this is needed so our module transformations don't break some core features *)
@@ -2244,7 +2432,7 @@ let generate con =
 			| _ -> assert false
 			| _ -> assert false
 	) "__get" "__set";
 	) "__get" "__set";
 
 
-	let field_is_dynamic t field =
+	let field_is_dynamic is_dynamic t field =
 		match field_access_esp gen (gen.greal_type t) field with
 		match field_access_esp gen (gen.greal_type t) field with
 			| FClassField (cl,p,_,_,_,t,_) ->
 			| FClassField (cl,p,_,_,_,t,_) ->
 				let p = change_param_type (TClassDecl cl) p in
 				let p = change_param_type (TClassDecl cl) p in
@@ -2258,14 +2446,18 @@ let generate con =
 		| _ -> false
 		| _ -> false
 	in
 	in
 
 
-	let is_dynamic_expr e =
+	let is_dynamic_expr is_dynamic e =
 		is_dynamic e.etype || match e.eexpr with
 		is_dynamic e.etype || match e.eexpr with
 		| TField(tf, f) ->
 		| TField(tf, f) ->
-			field_is_dynamic tf.etype f
+			field_is_dynamic is_dynamic tf.etype f
 		| _ ->
 		| _ ->
 			false
 			false
 	in
 	in
 
 
+	let is_dynamic_op t =
+		is_dynamic t || is_boxed_type (gen.greal_type t)
+	in
+
 	let may_nullable t = match gen.gfollow#run_f t with
 	let may_nullable t = match gen.gfollow#run_f t with
 		| TType({ t_path = ([], "Null") }, [t]) ->
 		| TType({ t_path = ([], "Null") }, [t]) ->
 			(match follow t with
 			(match follow t with
@@ -2283,20 +2475,29 @@ let generate con =
 	let is_double t = like_float t && not (like_int t) in
 	let is_double t = like_float t && not (like_int t) in
 	let is_int t = like_int t in
 	let is_int t = like_int t in
 
 
+	let nullable_basic t = match gen.gfollow#run_f t with
+		| TAbstract({ a_path = ([],"Null") }, [t])
+		| TType({ t_path = ([],"Null") }, [t]) when is_java_basic_type t ->
+			Some(t)
+		| _ ->
+			None
+	in
+
 	DynamicOperators.configure gen
 	DynamicOperators.configure gen
 		~handle_strings:true
 		~handle_strings:true
 		(fun e -> match e.eexpr with
 		(fun e -> match e.eexpr with
 			| TBinop (Ast.OpEq, e1, e2) ->
 			| TBinop (Ast.OpEq, e1, e2) ->
-				is_dynamic e1.etype || is_dynamic e2.etype || is_type_param e1.etype || is_type_param e2.etype
+				is_dynamic_op e1.etype || is_dynamic_op e2.etype || is_type_param e1.etype || is_type_param e2.etype
 			| TBinop (Ast.OpAdd, e1, e2)
 			| TBinop (Ast.OpAdd, e1, e2)
-			| TBinop (Ast.OpNotEq, e1, e2) -> is_dynamic e1.etype || is_dynamic e2.etype || is_type_param e1.etype || is_type_param e2.etype
+			| TBinop (Ast.OpNotEq, e1, e2) -> is_dynamic_op e1.etype || is_dynamic_op e2.etype || is_type_param e1.etype || is_type_param e2.etype
 			| TBinop (Ast.OpLt, e1, e2)
 			| TBinop (Ast.OpLt, e1, e2)
 			| TBinop (Ast.OpLte, e1, e2)
 			| TBinop (Ast.OpLte, e1, e2)
 			| TBinop (Ast.OpGte, e1, e2)
 			| TBinop (Ast.OpGte, e1, e2)
-			| TBinop (Ast.OpGt, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 || is_string e1.etype || is_string e2.etype
-			| TBinop (_, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2
+			| TBinop (Ast.OpGt, e1, e2) ->
+				is_dynamic_op e.etype || is_dynamic_op e1.etype || is_dynamic_op e2.etype || is_string e1.etype || is_string e2.etype
+			| TBinop (_, e1, e2) -> is_dynamic_op e.etype || is_dynamic_expr is_dynamic_op e1 || is_dynamic_expr is_dynamic_op e2
 			| TUnop (_, _, e1) ->
 			| TUnop (_, _, e1) ->
-				is_dynamic_expr e1
+				is_dynamic_expr is_dynamic_op e1
 			| _ -> false)
 			| _ -> false)
 		(fun e1 e2 ->
 		(fun e1 e2 ->
 			let is_null e = match e.eexpr with | TConst(TNull) | TLocal({ v_name = "__undefined__" }) -> true | _ -> false in
 			let is_null e = match e.eexpr with | TConst(TNull) | TLocal({ v_name = "__undefined__" }) -> true | _ -> false in
@@ -2304,7 +2505,7 @@ let generate con =
 			match e1.eexpr, e2.eexpr with
 			match e1.eexpr, e2.eexpr with
 				| TConst c1, TConst c2 when is_null e1 || is_null e2 ->
 				| TConst c1, TConst c2 when is_null e1 || is_null e2 ->
 					{ e1 with eexpr = TConst(TBool (c1 = c2)); etype = basic.tbool }
 					{ e1 with eexpr = TConst(TBool (c1 = c2)); etype = basic.tbool }
-				| _ when is_null e1 || is_null e2 && not (is_java_basic_type e1.etype || is_java_basic_type e2.etype) ->
+				| _ when (is_null e1 || is_null e2) && not (is_java_basic_type e1.etype || is_java_basic_type e2.etype) ->
 					{ e1 with eexpr = TBinop(Ast.OpEq, e1, e2); etype = basic.tbool }
 					{ e1 with eexpr = TBinop(Ast.OpEq, e1, e2); etype = basic.tbool }
 				| _ ->
 				| _ ->
 				let is_ref = match follow e1.etype, follow e2.etype with
 				let is_ref = match follow e1.etype, follow e2.etype with
@@ -2342,13 +2543,23 @@ let generate con =
 				| _ ->
 				| _ ->
 					let static = mk_static_field_access_infer (runtime_cl) "plus"  e1.epos [] in
 					let static = mk_static_field_access_infer (runtime_cl) "plus"  e1.epos [] in
 					mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos })
 					mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos })
-		(fun e1 e2 ->
-			if is_string e1.etype then begin
-				{ e1 with eexpr = TCall(mk_field_access gen e1 "compareTo" e1.epos, [ e2 ]); etype = gen.gcon.basic.tint }
-			end else begin
-				let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in
-				{ eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos }
-			end);
+		(fun op e e1 e2 ->
+				match nullable_basic e1.etype, nullable_basic e2.etype with
+					| Some(t1), None when is_java_basic_type e2.etype ->
+						{ e with eexpr = TBinop(op, mk_cast t1 e1, e2) }
+					| None, Some(t2) when is_java_basic_type e1.etype ->
+						{ e with eexpr = TBinop(op, e1, mk_cast t2 e2) }
+					| _ ->
+							let handler = if is_string e1.etype then begin
+									{ e1 with eexpr = TCall(mk_field_access gen e1 "compareTo" e1.epos, [ e2 ]); etype = gen.gcon.basic.tint }
+								end else begin
+									let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in
+									{ eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos }
+								end
+							in
+							let zero = ExprBuilder.make_int gen.gcon 0 e.epos in
+							{ e with eexpr = TBinop(op, handler, zero) }
+			);
 
 
 	let closure_cl = get_cl (get_type gen (["haxe";"lang"],"Closure")) in
 	let closure_cl = get_cl (get_type gen (["haxe";"lang"],"Closure")) in
 	FilterClosures.configure gen (fun e1 s -> true) (ReflectionCFs.get_closure_func rcf_ctx closure_cl);
 	FilterClosures.configure gen (fun e1 s -> true) (ReflectionCFs.get_closure_func rcf_ctx closure_cl);

+ 2 - 3
src/generators/genlua.ml

@@ -997,7 +997,7 @@ and gen_anon_value ctx e =
 	ctx.in_value <- fst old;
 	ctx.in_value <- fst old;
 	ctx.in_loop <- snd old;
 	ctx.in_loop <- snd old;
 	ctx.separator <- true
 	ctx.separator <- true
-    | { etype = TFun (args, ret)}  ->
+    | _ when (is_function_type ctx e.etype) ->
 	spr ctx "function(_,...) return ";
 	spr ctx "function(_,...) return ";
 	gen_value ctx e;
 	gen_value ctx e;
 	spr ctx "(...) end";
 	spr ctx "(...) end";
@@ -1141,9 +1141,8 @@ and gen_value ctx e =
 		v()
 		v()
 
 
 and is_function_type ctx t =
 and is_function_type ctx t =
-    match t with
+    match follow(t) with
     | TFun _ -> true
     | TFun _ -> true
-    | TMono r -> (match !r with | Some (TFun _) -> true | _ -> false)
     | _ -> false;
     | _ -> false;
 
 
 and gen_tbinop ctx op e1 e2 =
 and gen_tbinop ctx op e1 e2 =

+ 31 - 6
src/macro/eval/evalStdLib.ml

@@ -721,6 +721,27 @@ module StdDate = struct
 				tm_sec = int_of_string (Str.matched_group 6 s);
 				tm_sec = int_of_string (Str.matched_group 6 s);
 			} in
 			} in
 			encode_date (fst (Unix.mktime t))
 			encode_date (fst (Unix.mktime t))
+		| 10 ->
+			let r = Str.regexp "^\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\)$" in
+			if not (Str.string_match r s 0) then exc_string ("Invalid date format : " ^ s);
+			let t = Unix.localtime (Unix.time()) in
+			let t = { t with
+				tm_year = int_of_string (Str.matched_group 1 s) - 1900;
+				tm_mon = int_of_string (Str.matched_group 2 s) - 1;
+				tm_mday = int_of_string (Str.matched_group 3 s);
+				tm_hour = 0;
+				tm_min = 0;
+				tm_sec = 0;
+			} in
+			encode_date (fst (Unix.mktime t))
+		| 8 ->
+			let r = Str.regexp "^\\([0-9][0-9]\\):\\([0-9][0-9]\\):\\([0-9][0-9]\\)$" in
+			if not (Str.string_match r s 0) then exc_string ("Invalid date format : " ^ s);
+			let h = int_of_string (Str.matched_group 1 s) in
+			let m = int_of_string (Str.matched_group 2 s) in
+			let s = int_of_string (Str.matched_group 3 s) in
+			let t = h * 60 * 60 + m * 60 + s in
+			encode_date (float_of_int t)
 		| _ ->
 		| _ ->
 			exc_string ("Invalid date format : " ^ s)
 			exc_string ("Invalid date format : " ^ s)
 	)
 	)
@@ -1480,21 +1501,25 @@ module StdNativeProcess = struct
 		let len = decode_int len in
 		let len = decode_int len in
 		f this (Bytes.unsafe_to_string bytes) pos len
 		f this (Bytes.unsafe_to_string bytes) pos len
 
 
+	let process_catch f vthis =
+		try f (this vthis)
+		with Failure msg -> exc_string msg
+
 	let close = vifun0 (fun vthis ->
 	let close = vifun0 (fun vthis ->
-		Process.close (this vthis);
+		process_catch Process.close vthis;
 		vnull
 		vnull
 	)
 	)
 
 
 	let exitCode = vifun0 (fun vthis ->
 	let exitCode = vifun0 (fun vthis ->
-		vint (Process.exit (this vthis))
+		vint (process_catch Process.exit vthis)
 	)
 	)
 
 
 	let getPid = vifun0 (fun vthis ->
 	let getPid = vifun0 (fun vthis ->
-		vint (Process.pid (this vthis))
+		vint (process_catch Process.pid vthis)
 	)
 	)
 
 
 	let kill = vifun0 (fun vthis ->
 	let kill = vifun0 (fun vthis ->
-		Process.kill (this vthis);
+		process_catch Process.kill vthis;
 		vnull
 		vnull
 	)
 	)
 
 
@@ -1507,7 +1532,7 @@ module StdNativeProcess = struct
 	)
 	)
 
 
 	let closeStdin = vifun0 (fun vthis ->
 	let closeStdin = vifun0 (fun vthis ->
-		Process.close_stdin (this vthis);
+		process_catch Process.close_stdin vthis;
 		vnull
 		vnull
 	)
 	)
 
 
@@ -2687,7 +2712,7 @@ let init_constructors builtins =
 let init_empty_constructors builtins =
 let init_empty_constructors builtins =
 	let h = builtins.empty_constructor_builtins in
 	let h = builtins.empty_constructor_builtins in
 	Hashtbl.add h key_Array (fun () -> encode_array_instance (EvalArray.create [||]));
 	Hashtbl.add h key_Array (fun () -> encode_array_instance (EvalArray.create [||]));
-	Hashtbl.add h key_eval_Vector (fun () -> encode_vector_instance (Array.create 0 vnull));
+	Hashtbl.add h key_eval_Vector (fun () -> encode_vector_instance (Array.make 0 vnull));
 	Hashtbl.add h key_Date (fun () -> encode_instance key_Date ~kind:(IDate 0.));
 	Hashtbl.add h key_Date (fun () -> encode_instance key_Date ~kind:(IDate 0.));
 	Hashtbl.add h key_EReg (fun () -> encode_instance key_EReg ~kind:(IRegex {r = Pcre.regexp ""; r_global = false; r_string = ""; r_groups = [||]}));
 	Hashtbl.add h key_EReg (fun () -> encode_instance key_EReg ~kind:(IRegex {r = Pcre.regexp ""; r_global = false; r_string = ""; r_groups = [||]}));
 	Hashtbl.add h key_String (fun () -> encode_rope Rope.empty);
 	Hashtbl.add h key_String (fun () -> encode_rope Rope.empty);

+ 1 - 1
src/optimization/dce.ml

@@ -43,7 +43,7 @@ type dce = {
 (* check for @:keepSub metadata, which forces @:keep on child classes *)
 (* check for @:keepSub metadata, which forces @:keep on child classes *)
 let rec super_forces_keep c =
 let rec super_forces_keep c =
 	Meta.has Meta.KeepSub c.cl_meta || match c.cl_super with
 	Meta.has Meta.KeepSub c.cl_meta || match c.cl_super with
-	| Some (csup,_) -> super_forces_keep csup
+	| Some (csup,_) -> csup.cl_extern || super_forces_keep csup
 	| _ -> false
 	| _ -> false
 
 
 let is_std_file dce file =
 let is_std_file dce file =

+ 19 - 11
src/syntax/lexer.ml

@@ -196,11 +196,16 @@ let get_error_line p =
 	let l, _ = find_pos p in
 	let l, _ = find_pos p in
 	l
 	l
 
 
+let zero_based_columns = ref false
+
 let get_pos_coords p =
 let get_pos_coords p =
 	let file = find_file p.pfile in
 	let file = find_file p.pfile in
 	let l1, p1 = find_line p.pmin file in
 	let l1, p1 = find_line p.pmin file in
 	let l2, p2 = find_line p.pmax file in
 	let l2, p2 = find_line p.pmax file in
-	l1, p1, l2, p2
+	if !zero_based_columns then
+		l1, p1, l2, p2
+	else
+		l1, p1+1, l2, p2+1
 
 
 let get_error_pos printer p =
 let get_error_pos printer p =
 	if p.pmin = -1 then
 	if p.pmin = -1 then
@@ -397,36 +402,39 @@ and string2 lexbuf =
 	| "${" ->
 	| "${" ->
 		let pmin = lexeme_start lexbuf in
 		let pmin = lexeme_start lexbuf in
 		store lexbuf;
 		store lexbuf;
-		(try code_string lexbuf with Exit -> error Unclosed_code pmin);
+		(try code_string lexbuf 0 with Exit -> error Unclosed_code pmin);
 		string2 lexbuf;
 		string2 lexbuf;
 	| Plus (Compl ('\'' | '\\' | '\r' | '\n' | '$')) -> store lexbuf; string2 lexbuf
 	| Plus (Compl ('\'' | '\\' | '\r' | '\n' | '$')) -> store lexbuf; string2 lexbuf
 	| _ -> assert false
 	| _ -> assert false
 
 
-and code_string lexbuf =
+and code_string lexbuf open_braces =
 	match%sedlex lexbuf with
 	match%sedlex lexbuf with
 	| eof -> raise Exit
 	| eof -> raise Exit
-	| '\n' | '\r' | "\r\n" -> newline lexbuf; store lexbuf; code_string lexbuf
-	| '{' | '/' -> store lexbuf; code_string lexbuf
-	| '}' -> store lexbuf; (* stop *)
+	| '\n' | '\r' | "\r\n" -> newline lexbuf; store lexbuf; code_string lexbuf open_braces
+	| '{' -> store lexbuf; code_string lexbuf (open_braces + 1)
+	| '/' -> store lexbuf; code_string lexbuf open_braces
+	| '}' ->
+		store lexbuf;
+		if open_braces > 0 then code_string lexbuf (open_braces - 1)
 	| '"' ->
 	| '"' ->
 		add "\"";
 		add "\"";
 		let pmin = lexeme_start lexbuf in
 		let pmin = lexeme_start lexbuf in
 		(try ignore(string lexbuf) with Exit -> error Unterminated_string pmin);
 		(try ignore(string lexbuf) with Exit -> error Unterminated_string pmin);
 		add "\"";
 		add "\"";
-		code_string lexbuf
+		code_string lexbuf open_braces
 	| "'" ->
 	| "'" ->
 		add "'";
 		add "'";
 		let pmin = lexeme_start lexbuf in
 		let pmin = lexeme_start lexbuf in
 		let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in
 		let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in
 		add "'";
 		add "'";
 		fast_add_fmt_string { pfile = !cur.lfile; pmin = pmin; pmax = pmax };
 		fast_add_fmt_string { pfile = !cur.lfile; pmin = pmin; pmax = pmax };
-		code_string lexbuf
+		code_string lexbuf open_braces
 	| "/*" ->
 	| "/*" ->
 		let pmin = lexeme_start lexbuf in
 		let pmin = lexeme_start lexbuf in
 		(try ignore(comment lexbuf) with Exit -> error Unclosed_comment pmin);
 		(try ignore(comment lexbuf) with Exit -> error Unclosed_comment pmin);
-		code_string lexbuf
-	| "//", Star (Compl ('\n' | '\r')) -> store lexbuf; code_string lexbuf
-	| Plus (Compl ('/' | '"' | '\'' | '{' | '}' | '\n' | '\r')) -> store lexbuf; code_string lexbuf
+		code_string lexbuf open_braces
+	| "//", Star (Compl ('\n' | '\r')) -> store lexbuf; code_string lexbuf open_braces
+	| Plus (Compl ('/' | '"' | '\'' | '{' | '}' | '\n' | '\r')) -> store lexbuf; code_string lexbuf open_braces
 	| _ -> assert false
 	| _ -> assert false
 
 
 and regexp lexbuf =
 and regexp lexbuf =

+ 5 - 3
src/syntax/parser.mly

@@ -251,7 +251,7 @@ let reify in_macro =
 			| [] -> ei
 			| [] -> ei
 			| _ ->
 			| _ ->
 				(* `macro : $TP<Int>` conveys the intent to use TP and overwrite the
 				(* `macro : $TP<Int>` conveys the intent to use TP and overwrite the
-				   type parameters. *)
+					 type parameters. *)
 				let ea = to_array to_tparam t.tparams p in
 				let ea = to_array to_tparam t.tparams p in
 				let fields = [
 				let fields = [
 					("pack", (EField(ei,"pack"),p));
 					("pack", (EField(ei,"pack"),p));
@@ -365,7 +365,9 @@ let reify in_macro =
 	and to_expr e _ =
 	and to_expr e _ =
 		let p = snd e in
 		let p = snd e in
 		let expr n vl =
 		let expr n vl =
-			let e = mk_enum "ExprDef" n vl p in
+			(* We don't want the position of the call expression to span the entire call (#6396). *)
+			let pmin = {p with pmax = p.pmin} in
+			let e = mk_enum "ExprDef" n vl pmin in
 			to_obj [("expr",e);("pos",to_pos p)] p
 			to_obj [("expr",e);("pos",to_pos p)] p
 		in
 		in
 		let loop e = to_expr e (snd e) in
 		let loop e = to_expr e (snd e) in
@@ -510,7 +512,7 @@ let reify in_macro =
 					| Some _ -> begin
 					| Some _ -> begin
 						impl := (to_tpath t p) :: !impl;
 						impl := (to_tpath t p) :: !impl;
 						!ext
 						!ext
-					  end)
+						end)
 				| HImplements i-> impl := (to_tpath i p) :: !impl
 				| HImplements i-> impl := (to_tpath i p) :: !impl
 			) d.d_flags;
 			) d.d_flags;
 			to_obj [
 			to_obj [

+ 12 - 4
src/typing/matcher.ml

@@ -406,10 +406,18 @@ module Pattern = struct
 					pctx.current_locals <- PMap.add name (v,p) pctx.current_locals
 					pctx.current_locals <- PMap.add name (v,p) pctx.current_locals
 				) pctx1.current_locals;
 				) pctx1.current_locals;
 				PatOr(pat1,pat2)
 				PatOr(pat1,pat2)
-			| EBinop(OpAssign,(EConst (Ident s),p),e2) ->
-				let pat = make pctx t e2 in
-				let v = add_local s p in
-				PatBind(v,pat)
+			| EBinop(OpAssign,e1,e2) ->
+				let rec loop in_display e = match e with
+					| (EConst (Ident s),p) ->
+						let v = add_local s p in
+						if in_display then ignore(Typer.display_expr ctx e (mk (TLocal v) v.v_type p) (WithType t) p);
+						let pat = make pctx t e2 in
+						PatBind(v,pat)
+					| (EParenthesis e1,_) -> loop in_display e1
+					| (EDisplay(e1,_),_) -> loop true e1
+					| _ -> fail()
+					in
+					loop false e1
 			| EBinop(OpArrow,e1,e2) ->
 			| EBinop(OpArrow,e1,e2) ->
 				let v = add_local "_" null_pos in
 				let v = add_local "_" null_pos in
 				let e1 = type_expr ctx e1 Value in
 				let e1 = type_expr ctx e1 Value in

+ 80 - 115
src/typing/type.ml

@@ -364,8 +364,7 @@ let mk_mono() = TMono (ref None)
 
 
 let rec t_dynamic = TDynamic t_dynamic
 let rec t_dynamic = TDynamic t_dynamic
 
 
-let not_opened = ref Closed
-let mk_anon fl = TAnon { a_fields = fl; a_status = not_opened; }
+let mk_anon fl = TAnon { a_fields = fl; a_status = ref Closed; }
 
 
 (* We use this for display purposes because otherwise we never see the Dynamic type that
 (* We use this for display purposes because otherwise we never see the Dynamic type that
    is defined in StdTypes.hx. This is set each time a typer is created, but this is fine
    is defined in StdTypes.hx. This is set each time a typer is created, but this is fine
@@ -1640,6 +1639,38 @@ let unify_kind k1 k2 =
 
 
 let eq_stack = ref []
 let eq_stack = ref []
 
 
+let rec_stack stack value fcheck frun ferror =
+	if not (List.exists fcheck !stack) then begin
+		try
+			stack := value :: !stack;
+			let v = frun() in
+			stack := List.tl !stack;
+			v
+		with
+			Unify_error l ->
+				stack := List.tl !stack;
+				ferror l
+			| e ->
+				stack := List.tl !stack;
+				raise e
+	end
+
+let rec_stack_bool stack value fcheck frun =
+	if (List.exists fcheck !stack) then false else begin
+		try
+			stack := value :: !stack;
+			frun();
+			stack := List.tl !stack;
+			true
+		with
+			Unify_error l ->
+				stack := List.tl !stack;
+				false
+			| e ->
+				stack := List.tl !stack;
+				raise e
+	end
+
 type eq_kind =
 type eq_kind =
 	| EqStrict
 	| EqStrict
 	| EqCoreType
 	| EqCoreType
@@ -1671,18 +1702,10 @@ let rec type_eq param a b =
 	| TType (t,tl) , _ when can_follow a ->
 	| TType (t,tl) , _ when can_follow a ->
 		type_eq param (apply_params t.t_params tl t.t_type) b
 		type_eq param (apply_params t.t_params tl t.t_type) b
 	| _ , TType (t,tl) when can_follow b ->
 	| _ , TType (t,tl) when can_follow b ->
-		if List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!eq_stack) then
-			()
-		else begin
-			eq_stack := (a,b) :: !eq_stack;
-			try
-				type_eq param a (apply_params t.t_params tl t.t_type);
-				eq_stack := List.tl !eq_stack;
-			with
-				Unify_error l ->
-					eq_stack := List.tl !eq_stack;
-					error (cannot_unify a b :: l)
-		end
+		rec_stack eq_stack (a,b)
+			(fun (a2,b2) -> fast_eq a a2 && fast_eq b b2)
+			(fun() -> type_eq param a (apply_params t.t_params tl t.t_type))
+			(fun l -> error (cannot_unify a b :: l))
 	| TEnum (e1,tl1) , TEnum (e2,tl2) ->
 	| TEnum (e1,tl1) , TEnum (e2,tl2) ->
 		if e1 != e2 && not (param = EqCoreType && e1.e_path = e2.e_path) then error [cannot_unify a b];
 		if e1 != e2 && not (param = EqCoreType && e1.e_path = e2.e_path) then error [cannot_unify a b];
 		List.iter2 (type_eq param) tl1 tl2
 		List.iter2 (type_eq param) tl1 tl2
@@ -1710,16 +1733,10 @@ let rec type_eq param a b =
 					let f2 = PMap.find n a2.a_fields in
 					let f2 = PMap.find n a2.a_fields in
 					if f1.cf_kind <> f2.cf_kind && (param = EqStrict || param = EqCoreType || not (unify_kind f1.cf_kind f2.cf_kind)) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 					if f1.cf_kind <> f2.cf_kind && (param = EqStrict || param = EqCoreType || not (unify_kind f1.cf_kind f2.cf_kind)) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 					let a = f1.cf_type and b = f2.cf_type in
 					let a = f1.cf_type and b = f2.cf_type in
-					if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!eq_stack)) then begin
-						eq_stack := (a,b) :: !eq_stack;
-						try
-							type_eq param a b;
-							eq_stack := List.tl !eq_stack;
-						with
-							Unify_error l ->
-								eq_stack := List.tl !eq_stack;
-								error (invalid_field n :: l)
-					end;
+					rec_stack eq_stack (a,b)
+						(fun (a2,b2) -> fast_eq a a2 && fast_eq b b2)
+						(fun() -> type_eq param a b)
+						(fun l -> error (invalid_field n :: l))
 				with
 				with
 					Not_found ->
 					Not_found ->
 						if is_closed a2 then error [has_no_field b n];
 						if is_closed a2 then error [has_no_field b n];
@@ -1786,27 +1803,15 @@ let rec unify a b =
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| Some t -> unify a t)
 		| Some t -> unify a t)
 	| TType (t,tl) , _ ->
 	| TType (t,tl) , _ ->
-		if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!unify_stack)) then begin
-			try
-				unify_stack := (a,b) :: !unify_stack;
-				unify (apply_params t.t_params tl t.t_type) b;
-				unify_stack := List.tl !unify_stack;
-			with
-				Unify_error l ->
-					unify_stack := List.tl !unify_stack;
-					error (cannot_unify a b :: l)
-		end
+		rec_stack unify_stack (a,b)
+			(fun(a2,b2) -> fast_eq a a2 && fast_eq b b2)
+			(fun() -> unify (apply_params t.t_params tl t.t_type) b)
+			(fun l -> error (cannot_unify a b :: l))
 	| _ , TType (t,tl) ->
 	| _ , TType (t,tl) ->
-		if not (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!unify_stack)) then begin
-			try
-				unify_stack := (a,b) :: !unify_stack;
-				unify a (apply_params t.t_params tl t.t_type);
-				unify_stack := List.tl !unify_stack;
-			with
-				Unify_error l ->
-					unify_stack := List.tl !unify_stack;
-					error (cannot_unify a b :: l)
-		end
+		rec_stack unify_stack (a,b)
+			(fun(a2,b2) -> fast_eq a a2 && fast_eq b b2)
+			(fun() -> unify a (apply_params t.t_params tl t.t_type))
+			(fun l -> error (cannot_unify a b :: l))
 	| TEnum (ea,tl1) , TEnum (eb,tl2) ->
 	| TEnum (ea,tl1) , TEnum (eb,tl2) ->
 		if ea != eb then error [cannot_unify a b];
 		if ea != eb then error [cannot_unify a b];
 		unify_type_params a b tl1 tl2
 		unify_type_params a b tl1 tl2
@@ -1894,33 +1899,19 @@ let rec unify a b =
 					(* we will do a recursive unification, so let's check for possible recursion *)
 					(* we will do a recursive unification, so let's check for possible recursion *)
 					let old_monos = !unify_new_monos in
 					let old_monos = !unify_new_monos in
 					unify_new_monos := !monos @ !unify_new_monos;
 					unify_new_monos := !monos @ !unify_new_monos;
-					if not (List.exists (fun (a2,b2) -> fast_eq b2 f2.cf_type && fast_eq_mono !unify_new_monos ft a2) (!unify_stack)) then begin
-						unify_stack := (ft,f2.cf_type) :: !unify_stack;
-						(try
-							unify_with_access ft f2
-						with
-							Unify_error l ->
-								unify_new_monos := old_monos;
-								unify_stack := List.tl !unify_stack;
-								error (invalid_field n :: l));
-						unify_stack := List.tl !unify_stack;
-					end;
+					rec_stack unify_stack (ft,f2.cf_type)
+						(fun (a2,b2) -> fast_eq b2 f2.cf_type && fast_eq_mono !unify_new_monos ft a2)
+						(fun() -> try unify_with_access ft f2 with e -> unify_new_monos := old_monos; raise e)
+						(fun l -> error (invalid_field n :: l));
 					unify_new_monos := old_monos;
 					unify_new_monos := old_monos;
 				| Method MethNormal | Method MethInline | Var { v_write = AccNo } | Var { v_write = AccNever } ->
 				| Method MethNormal | Method MethInline | Var { v_write = AccNo } | Var { v_write = AccNever } ->
 					(* same as before, but unification is reversed (read-only var) *)
 					(* same as before, but unification is reversed (read-only var) *)
 					let old_monos = !unify_new_monos in
 					let old_monos = !unify_new_monos in
 					unify_new_monos := !monos @ !unify_new_monos;
 					unify_new_monos := !monos @ !unify_new_monos;
-					if not (List.exists (fun (a2,b2) -> fast_eq_mono !unify_new_monos b2 ft && fast_eq f2.cf_type a2) (!unify_stack)) then begin
-						unify_stack := (f2.cf_type,ft) :: !unify_stack;
-						(try
-							unify_with_access ft f2
-						with
-							Unify_error l ->
-								unify_new_monos := old_monos;
-								unify_stack := List.tl !unify_stack;
-								error (invalid_field n :: l));
-						unify_stack := List.tl !unify_stack;
-					end;
+					rec_stack unify_stack (f2.cf_type,ft)
+						(fun(a2,b2) -> fast_eq_mono !unify_new_monos b2 ft && fast_eq f2.cf_type a2)
+						(fun() -> try unify_with_access ft f2 with e -> unify_new_monos := old_monos; raise e)
+						(fun l -> error (invalid_field n :: l));
 					unify_new_monos := old_monos;
 					unify_new_monos := old_monos;
 				| _ ->
 				| _ ->
 					(* will use fast_eq, which have its own stack *)
 					(* will use fast_eq, which have its own stack *)
@@ -2089,19 +2080,12 @@ and unify_anons a b a1 a2 =
 		Unify_error l -> error (cannot_unify a b :: l))
 		Unify_error l -> error (cannot_unify a b :: l))
 
 
 and unify_from ab tl a b ?(allow_transitive_cast=true) t =
 and unify_from ab tl a b ?(allow_transitive_cast=true) t =
-	if (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!abstract_cast_stack)) then false else begin
-	abstract_cast_stack := (a,b) :: !abstract_cast_stack;
-	let t = apply_params ab.a_params tl t in
-	let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
-	let b = try
-		unify_func a t;
-		true
-	with Unify_error _ ->
-		false
-	in
-	abstract_cast_stack := List.tl !abstract_cast_stack;
-	b
-	end
+	rec_stack_bool abstract_cast_stack (a,b)
+		(fun (a2,b2) -> fast_eq a a2 && fast_eq b b2)
+		(fun() ->
+			let t = apply_params ab.a_params tl t in
+			let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
+			unify_func a t)
 
 
 and unify_to ab tl b ?(allow_transitive_cast=true) t =
 and unify_to ab tl b ?(allow_transitive_cast=true) t =
 	let t = apply_params ab.a_params tl t in
 	let t = apply_params ab.a_params tl t in
@@ -2113,11 +2097,11 @@ and unify_to ab tl b ?(allow_transitive_cast=true) t =
 		false
 		false
 
 
 and unify_from_field ab tl a b ?(allow_transitive_cast=true) (t,cf) =
 and unify_from_field ab tl a b ?(allow_transitive_cast=true) (t,cf) =
-	if (List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!abstract_cast_stack)) then false else begin
-	abstract_cast_stack := (a,b) :: !abstract_cast_stack;
-	let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
-	let b = try
-		begin match follow cf.cf_type with
+	rec_stack_bool abstract_cast_stack (a,b)
+		(fun (a2,b2) -> fast_eq a a2 && fast_eq b b2)
+		(fun() ->
+			let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
+			match follow cf.cf_type with
 			| TFun(_,r) ->
 			| TFun(_,r) ->
 				let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 				let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 				let map t = apply_params ab.a_params tl (apply_params cf.cf_params monos t) in
 				let map t = apply_params ab.a_params tl (apply_params cf.cf_params monos t) in
@@ -2128,22 +2112,16 @@ and unify_from_field ab tl a b ?(allow_transitive_cast=true) (t,cf) =
 					| _ -> ()
 					| _ -> ()
 				) monos cf.cf_params;
 				) monos cf.cf_params;
 				unify_func (map r) b;
 				unify_func (map r) b;
-			| _ -> assert false
-		end;
-		true
-	with Unify_error _ -> false
-	in
-	abstract_cast_stack := List.tl !abstract_cast_stack;
-	b
-	end
+				true
+			| _ -> assert false)
 
 
 and unify_to_field ab tl b ?(allow_transitive_cast=true) (t,cf) =
 and unify_to_field ab tl b ?(allow_transitive_cast=true) (t,cf) =
 	let a = TAbstract(ab,tl) in
 	let a = TAbstract(ab,tl) in
-	if (List.exists (fun (b2,a2) -> fast_eq a a2 && fast_eq b b2) (!abstract_cast_stack)) then false else begin
-	abstract_cast_stack := (b,a) :: !abstract_cast_stack;
-	let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
-	let r = try
-		begin match follow cf.cf_type with
+	rec_stack_bool abstract_cast_stack (b,a)
+		(fun (b2,a2) -> fast_eq a a2 && fast_eq b b2)
+		(fun() ->
+			let unify_func = if allow_transitive_cast then unify else type_eq EqStrict in
+			match follow cf.cf_type with
 			| TFun((_,_,ta) :: _,_) ->
 			| TFun((_,_,ta) :: _,_) ->
 				let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 				let monos = List.map (fun _ -> mk_mono()) cf.cf_params in
 				let map t = apply_params ab.a_params tl (apply_params cf.cf_params monos t) in
 				let map t = apply_params ab.a_params tl (apply_params cf.cf_params monos t) in
@@ -2158,14 +2136,7 @@ and unify_to_field ab tl b ?(allow_transitive_cast=true) (t,cf) =
 					| _ -> ()
 					| _ -> ()
 				) monos cf.cf_params;
 				) monos cf.cf_params;
 				unify_func (map t) b;
 				unify_func (map t) b;
-			| _ -> assert false
-		end;
-		true
-	with Unify_error _ -> false
-	in
-	abstract_cast_stack := List.tl !abstract_cast_stack;
-	r
-	end
+			| _ -> assert false)
 
 
 and unify_with_variance f t1 t2 =
 and unify_with_variance f t1 t2 =
 	let allows_variance_to t tf = type_iseq tf t in
 	let allows_variance_to t tf = type_iseq tf t in
@@ -2191,16 +2162,10 @@ and unify_with_variance f t1 t2 =
 		type_eq EqBothDynamic t (apply_params a.a_params pl a.a_this);
 		type_eq EqBothDynamic t (apply_params a.a_params pl a.a_this);
 		if not (List.exists (fun t2 -> allows_variance_to t (apply_params a.a_params pl t2)) a.a_from) then error [cannot_unify t1 t2]
 		if not (List.exists (fun t2 -> allows_variance_to t (apply_params a.a_params pl t2)) a.a_from) then error [cannot_unify t1 t2]
 	| (TAnon a1 as t1), (TAnon a2 as t2) ->
 	| (TAnon a1 as t1), (TAnon a2 as t2) ->
-		if not (List.exists (fun (a,b) -> fast_eq a t1 && fast_eq b t2) (!unify_stack)) then begin
-			try
-				unify_stack := (t1,t2) :: !unify_stack;
-				unify_anons t1 t2 a1 a2;
-				unify_stack := List.tl !unify_stack;
-			with
-				Unify_error l ->
-					unify_stack := List.tl !unify_stack;
-					error l
-		end
+		rec_stack unify_stack (t1,t2)
+			(fun (a,b) -> fast_eq a t1 && fast_eq b t2)
+			(fun() -> unify_anons t1 t2 a1 a2)
+			(fun l -> error l)
 	| _ ->
 	| _ ->
 		error [cannot_unify t1 t2]
 		error [cannot_unify t1 t2]
 
 

+ 2 - 2
src/typing/typeload.ml

@@ -1778,7 +1778,7 @@ let check_global_metadata ctx meta f_add mpath tpath so =
 		let add = ((field_mode && to_fields) || (not field_mode && to_types)) && (match_path recursive sl1 sl2) in
 		let add = ((field_mode && to_fields) || (not field_mode && to_types)) && (match_path recursive sl1 sl2) in
 		if add then f_add m
 		if add then f_add m
 	) ctx.g.global_metadata;
 	) ctx.g.global_metadata;
-	if ctx.is_display_file then Display.DisplayEmitter.check_display_metadata ctx meta
+	if ctx.is_display_file then delay ctx PCheckConstraint (fun () -> Display.DisplayEmitter.check_display_metadata ctx meta)
 
 
 let patch_class ctx c fields =
 let patch_class ctx c fields =
 	let path = match c.cl_kind with
 	let path = match c.cl_kind with
@@ -2951,7 +2951,7 @@ let init_module_type ctx context_init do_init (decl,p) =
 	in
 	in
 	let check_path_display path p = match ctx.com.display.dms_kind with
 	let check_path_display path p = match ctx.com.display.dms_kind with
 		(* We cannot use ctx.is_display_file because the import could come from an import.hx file. *)
 		(* We cannot use ctx.is_display_file because the import could come from an import.hx file. *)
-		| DMDiagnostics b when (b && not (ExtString.String.ends_with p.pfile "import.hx")) || Display.is_display_file p.pfile ->
+		| DMDiagnostics b when (b || Display.is_display_file p.pfile) && not (ExtString.String.ends_with p.pfile "import.hx") ->
 			Display.ImportHandling.add_import_position ctx.com p path;
 			Display.ImportHandling.add_import_position ctx.com p path;
 		| DMStatistics | DMUsage _ ->
 		| DMStatistics | DMUsage _ ->
 			Display.ImportHandling.add_import_position ctx.com p path;
 			Display.ImportHandling.add_import_position ctx.com p path;

+ 3 - 1
std/cs/_std/haxe/ds/IntMap.hx

@@ -291,6 +291,8 @@ import cs.NativeArray;
 					var key = _keys[j];
 					var key = _keys[j];
 					var val = vals[j];
 					var val = vals[j];
 
 
+					_keys[j] = 0;
+					vals[j] = cast null;
 					setIsDelTrue(flags, j);
 					setIsDelTrue(flags, j);
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{
@@ -362,7 +364,7 @@ import cs.NativeArray;
 	{
 	{
 		return new IntMapValueIterator(this);
 		return new IntMapValueIterator(this);
 	}
 	}
-	
+
 	public function copy() : IntMap<T> {
 	public function copy() : IntMap<T> {
 		var copied = new IntMap<T>();
 		var copied = new IntMap<T>();
 		for(key in keys()) copied.set(key, get(key));
 		for(key in keys()) copied.set(key, get(key));

+ 3 - 1
std/cs/_std/haxe/ds/ObjectMap.hx

@@ -219,6 +219,8 @@ import cs.NativeArray;
 					var key = _keys[j];
 					var key = _keys[j];
 					var val = vals[j];
 					var val = vals[j];
 
 
+					_keys[j] = null;
+					vals[j] = cast null;
 					hashes[j] = FLAG_DEL;
 					hashes[j] = FLAG_DEL;
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{
@@ -392,7 +394,7 @@ import cs.NativeArray;
 	{
 	{
 		return new ObjectMapValueIterator(this);
 		return new ObjectMapValueIterator(this);
 	}
 	}
-	
+
 	public function copy() : ObjectMap<K,V> {
 	public function copy() : ObjectMap<K,V> {
 		var copied = new ObjectMap<K, V>();
 		var copied = new ObjectMap<K, V>();
 		for(key in keys()) copied.set(key, get(key));
 		for(key in keys()) copied.set(key, get(key));

+ 2 - 0
std/cs/_std/haxe/ds/StringMap.hx

@@ -218,6 +218,8 @@ import cs.NativeArray;
 					var key = _keys[j];
 					var key = _keys[j];
 					var val = vals[j];
 					var val = vals[j];
 
 
+					_keys[j] = null;
+					vals[j] = cast null;
 					hashes[j] = FLAG_DEL;
 					hashes[j] = FLAG_DEL;
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{

+ 0 - 3
std/haxe/CallStack.hx

@@ -208,9 +208,6 @@ class CallStack {
 					stack.push( method );
 					stack.push( method );
 				}
 				}
 			}
 			}
-			// stack.shift();
-			stack.shift();
-			stack.pop();
 			return stack;
 			return stack;
 		#elseif cs
 		#elseif cs
 			return makeStack(new cs.system.diagnostics.StackTrace(cs.internal.Exceptions.exception, true));
 			return makeStack(new cs.system.diagnostics.StackTrace(cs.internal.Exceptions.exception, true));

+ 11 - 0
std/haxe/ds/GenericStack.hx

@@ -37,6 +37,15 @@ class GenericCell<T> {
 
 
 #if cpp
 #if cpp
 @:generic
 @:generic
+#if cppia
+private class GenericStackIterator<T> {
+	public var current : GenericCell<T>;
+	public function hasNext():Bool { return current!=null; }
+	public function next():T { var result = current.elt; current = current.next; return result; }
+
+	public function new(head) { current = head; }
+}
+#else
 private class GenericStackIterator<T> extends cpp.FastIterator<T> {
 private class GenericStackIterator<T> extends cpp.FastIterator<T> {
 	public var current : GenericCell<T>;
 	public var current : GenericCell<T>;
 	override public function hasNext():Bool { return current!=null; }
 	override public function hasNext():Bool { return current!=null; }
@@ -44,6 +53,8 @@ private class GenericStackIterator<T> extends cpp.FastIterator<T> {
 
 
 	public function new(head) { current = head; }
 	public function new(head) { current = head; }
 }
 }
+#end
+
 
 
 #end
 #end
 
 

+ 44 - 105
std/java/_std/Type.hx

@@ -124,121 +124,60 @@ enum ValueType {
 		return resolveClass(name);
 		return resolveClass(name);
 	}
 	}
 
 
-	@:functionCode('
-			int len = args.length;
-			java.lang.Class[] cls = new java.lang.Class[len];
-			java.lang.Object[] objs = new java.lang.Object[len];
-
-			java.lang.reflect.Constructor[] ms = cl.getConstructors();
-			int msl = ms.length;
-			int realMsl = 0;
-			for(int i =0; i < msl; i++)
-			{
-				if (!ms[i].isVarArgs() && ms[i].getParameterTypes().length != len)
-				{
-					ms[i] = null;
-				} else {
-					ms[realMsl] = ms[i];
-					if (realMsl != i)
-						ms[i] = null;
-					realMsl++;
-				}
-			}
-
-			boolean hasNumber = false;
-
-			for (int i = 0; i < len; i++)
-			{
-				Object o = args.__get(i);
-				objs[i]= o;
-				cls[i] = o.getClass();
-				boolean isNum = false;
-
-				if (o instanceof java.lang.Number)
-				{
-					cls[i] = java.lang.Number.class;
-					isNum = hasNumber = true;
-				}
+	public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T
+	{
+		var nargs = args.length,
+				callArguments = new java.NativeArray<Dynamic>(nargs);
 
 
-				msl = realMsl;
-				realMsl = 0;
-
-				for (int j = 0; j < msl; j++)
-				{
-					java.lang.Class[] allcls = ms[j].getParameterTypes();
-					if (i < allcls.length)
-					{
-						if (! ((isNum && allcls[i].isPrimitive()) || allcls[i].isAssignableFrom(cls[i])) )
-						{
-							ms[j] = null;
-						} else {
-							ms[realMsl] = ms[j];
-							if (realMsl != j)
-								ms[j] = null;
-							realMsl++;
-						}
-					}
-				}
+		var ctors = java.Lib.toNativeType(cl).getConstructors(),
+				totalCtors = ctors.length,
+				validCtors = 0;
 
 
+		for (i in 0...totalCtors) {
+			var ctor = ctors[i];
+			var ptypes = ctor.getParameterTypes();
+			if (ptypes.length != nargs && !ctor.isVarArgs()) {
+				continue;
 			}
 			}
 
 
-			java.lang.reflect.Constructor found = ms[0];
-
-			if (hasNumber)
-			{
-				java.lang.Class[] allcls = found.getParameterTypes();
-
-				for (int i = 0; i < len; i++)
-				{
-					java.lang.Object o = objs[i];
-					if (o instanceof java.lang.Number)
-					{
-						java.lang.Class curCls = null;
-						if (i < allcls.length)
-						{
-							curCls = allcls[i];
-							if (!curCls.isAssignableFrom(o.getClass()))
-							{
-								String name = curCls.getName();
-								if (name.equals("double") || name.equals("java.lang.Double"))
-								{
-									objs[i] = ((java.lang.Number)o).doubleValue();
-								} else if (name.equals("int") || name.equals("java.lang.Integer"))
-								{
-									objs[i] = ((java.lang.Number)o).intValue();
-								} else if (name.equals("float") || name.equals("java.lang.Float"))
-								{
-									objs[i] = ((java.lang.Number)o).floatValue();
-								} else if (name.equals("byte") || name.equals("java.lang.Byte"))
-								{
-									objs[i] = ((java.lang.Number)o).byteValue();
-								} else if (name.equals("short") || name.equals("java.lang.Short"))
-								{
-									objs[i] = ((java.lang.Number)o).shortValue();
-								}
-							}
-						} //else varargs not handled TODO
+			var argNum = -1,
+					valid = true;
+			for (arg in args) {
+				argNum++;
+				var expectedType = argNum < ptypes.length ? ptypes[argNum] : ptypes[ptypes.length - 1]; // varags
+				if (arg == null || expectedType.isAssignableFrom(java.Lib.toNativeType(Type.getClass(arg)))) {
+					callArguments[argNum] = arg;
+				} else if (Std.is(arg, java.lang.Number)) {
+					var name = expectedType.getName();
+					switch(name) {
+						case 'double' | 'java.lang.Double':
+							callArguments[argNum] = (cast arg : java.lang.Number).doubleValue();
+						case 'int' | 'java.lang.Integer':
+							callArguments[argNum] = (cast arg : java.lang.Number).intValue();
+						case 'float' | 'java.lang.Float':
+							callArguments[argNum] = (cast arg : java.lang.Number).floatValue();
+						case 'byte' | 'java.lang.Byte':
+							callArguments[argNum] = (cast arg : java.lang.Number).byteValue();
+						case 'short' | 'java.lang.Short':
+							callArguments[argNum] = (cast arg : java.lang.Number).shortValue();
+						case _:
+							throw 'Unknown expected number subclass of type $name';
 					}
 					}
+				} else {
+					valid = false;
+					break;
 				}
 				}
 			}
 			}
+			if (!valid) {
+				continue;
+			}
 
 
-		try {
-			found.setAccessible(true);
-			return (T) found.newInstance(objs);
-		}
-		catch (java.lang.reflect.InvocationTargetException e)
-		{
-			throw haxe.lang.HaxeException.wrap(e.getCause());
+			// the current constructor was found and it is valid - call it
+			ctor.setAccessible(true);
+			return cast ctor.newInstance(callArguments);
 		}
 		}
 
 
-		catch (Throwable t)
-		{
-			throw haxe.lang.HaxeException.wrap(t);
-		}
-	')
-	public static function createInstance<T>( cl : Class<T>, args : Array<Dynamic> ) : T untyped
-	{
-		return null;
+		throw 'Could not find any constructor that matches the provided arguments for class $cl';
 	}
 	}
 
 
 	// cache empty constructor arguments so we don't allocate it on each createEmptyInstance call
 	// cache empty constructor arguments so we don't allocate it on each createEmptyInstance call

+ 3 - 1
std/java/_std/haxe/ds/IntMap.hx

@@ -273,6 +273,8 @@ import java.NativeArray;
 					var key = _keys[j];
 					var key = _keys[j];
 					var val = vals[j];
 					var val = vals[j];
 
 
+					_keys[j] = 0;
+					vals[j] = cast null;
 					setIsDelTrue(flags, j);
 					setIsDelTrue(flags, j);
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{
@@ -385,7 +387,7 @@ import java.NativeArray;
 			}
 			}
 		};
 		};
 	}
 	}
-	
+
 	public function copy() : IntMap<T> {
 	public function copy() : IntMap<T> {
 		var copied = new IntMap();
 		var copied = new IntMap();
 		for(key in keys()) copied.set(key, get(key));
 		for(key in keys()) copied.set(key, get(key));

+ 4 - 2
std/java/_std/haxe/ds/ObjectMap.hx

@@ -211,6 +211,8 @@ import java.NativeArray;
 					var key = _keys[j];
 					var key = _keys[j];
 					var val = vals[j];
 					var val = vals[j];
 
 
+					_keys[j] = null;
+					vals[j] = cast null;
 					hashes[j] = FLAG_DEL;
 					hashes[j] = FLAG_DEL;
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{
@@ -409,8 +411,8 @@ import java.NativeArray;
 			}
 			}
 		};
 		};
 	}
 	}
-	
-	
+
+
 	public function copy() : ObjectMap<K,V> {
 	public function copy() : ObjectMap<K,V> {
 		var copied = new ObjectMap();
 		var copied = new ObjectMap();
 		for(key in keys()) copied.set(key, get(key));
 		for(key in keys()) copied.set(key, get(key));

+ 3 - 2
std/java/_std/haxe/ds/WeakMap.hx

@@ -245,6 +245,7 @@ import java.lang.ref.ReferenceQueue;
 				{
 				{
 					var entry = entries[j];
 					var entry = entries[j];
 
 
+					entries[j] = null;
 					hashes[j] = FLAG_DEL;
 					hashes[j] = FLAG_DEL;
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					while (true) /* kick-out process; sort of like in Cuckoo hashing */
 					{
 					{
@@ -447,8 +448,8 @@ import java.lang.ref.ReferenceQueue;
 			}
 			}
 		};
 		};
 	}
 	}
-	
-	
+
+
 	public function copy() : WeakMap<K,V> {
 	public function copy() : WeakMap<K,V> {
 		var copied = new WeakMap();
 		var copied = new WeakMap();
 		for(key in keys()) copied.set(key, get(key));
 		for(key in keys()) copied.set(key, get(key));

+ 38 - 5
std/java/internal/Runtime.hx

@@ -127,12 +127,9 @@ package java.internal;
 		return 0.0;
 		return 0.0;
 	}
 	}
 
 
-	@:functionCode('
-		return (obj == null) ? false : ((java.lang.Boolean) obj).booleanValue();
-	')
-	public static function toBool(obj:Dynamic):Bool
+	public static function toBool(obj:java.lang.Boolean):Bool
 	{
 	{
-		return false;
+		return obj == null ? false : obj.booleanValue();
 	}
 	}
 
 
 	@:functionCode('
 	@:functionCode('
@@ -582,6 +579,42 @@ package java.internal;
 	{
 	{
 		return (v == v) && !java.lang.Double.DoubleClass._isInfinite(v);
 		return (v == v) && !java.lang.Double.DoubleClass._isInfinite(v);
 	}
 	}
+
+	public static function getIntFromNumber(n:java.lang.Number):Int {
+		return n == null ? 0 : n.intValue();
+	}
+
+	public static function getFloatFromNumber(n:java.lang.Number):Float {
+		return n == null ? 0.0 : n.doubleValue();
+	}
+
+	public static function getInt64FromNumber(n:java.lang.Number):java.StdTypes.Int64 {
+		return n == null ? 0.0 : n.longValue();
+	}
+
+	public static function numToInteger(num:java.lang.Number):java.lang.Integer {
+		return num == null ? null : (Std.is(num, java.lang.Integer.IntegerClass) ? cast num : java.lang.Integer.valueOf(num.intValue()));
+	}
+
+	public static function numToDouble(num:java.lang.Number):java.lang.Double {
+		return num == null ? null : (Std.is(num, java.lang.Double.DoubleClass) ? cast num : java.lang.Double.valueOf(num.doubleValue()));
+	}
+
+	public static function numToFloat(num:java.lang.Number):java.lang.Float {
+		return num == null ? null : (Std.is(num, java.lang.Float.FloatClass) ? cast num : java.lang.Float.valueOf(num.floatValue()));
+	}
+
+	public static function numToByte(num:java.lang.Number):java.lang.Byte {
+		return num == null ? null : (Std.is(num, java.lang.Byte.ByteClass) ? cast num : java.lang.Byte.valueOf(num.byteValue()));
+	}
+
+	public static function numToLong(num:java.lang.Number):java.lang.Long {
+		return num == null ? null : (Std.is(num, java.lang.Long.LongClass) ? cast num : java.lang.Long.valueOf(num.longValue()));
+	}
+
+	public static function numToShort(num:java.lang.Number):java.lang.Short {
+		return num == null ? null : (Std.is(num, java.lang.Short.ShortClass) ? cast num : java.lang.Short.valueOf(num.shortValue()));
+	}
 }
 }
 
 
 @:keep @:native("haxe.lang.EmptyObject") enum EmptyObject
 @:keep @:native("haxe.lang.EmptyObject") enum EmptyObject

+ 1 - 1
std/java/lang/Double.hx

@@ -61,6 +61,6 @@
 	@:overload @:throws("java.lang.NumberFormatException") static function parseDouble(param1 : String) : Float;
 	@:overload @:throws("java.lang.NumberFormatException") static function parseDouble(param1 : String) : Float;
 	@:overload static function toHexString(param1 : Float) : String;
 	@:overload static function toHexString(param1 : Float) : String;
 	@:native("toString") @:overload static function _toString(param1 : Float) : String;
 	@:native("toString") @:overload static function _toString(param1 : Float) : String;
-	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Double;
 	@:overload static function valueOf(param1 : Float) : Double;
 	@:overload static function valueOf(param1 : Float) : Double;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Double;
 }
 }

+ 1 - 1
std/java/lang/Float.hx

@@ -62,8 +62,8 @@
 	@:overload @:throws("java.lang.NumberFormatException") static function parseFloat(param1 : String) : Single;
 	@:overload @:throws("java.lang.NumberFormatException") static function parseFloat(param1 : String) : Single;
 	@:overload static function toHexString(param1 : Single) : String;
 	@:overload static function toHexString(param1 : Single) : String;
 	@:native("toString") @:overload static function _toString(param1 : Single) : String;
 	@:native("toString") @:overload static function _toString(param1 : Single) : String;
-	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Float;
 	@:overload static function valueOf(param1 : Single) : Float;
 	@:overload static function valueOf(param1 : Single) : Float;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Float;
 
 
 }
 }
 
 

+ 1 - 1
std/java/lang/Integer.hx

@@ -66,8 +66,8 @@
 	@:overload static function toOctalString(param1 : Int) : String;
 	@:overload static function toOctalString(param1 : Int) : String;
 	@:native("toString") @:overload static function _toString(param1 : Int, param2 : Int) : String;
 	@:native("toString") @:overload static function _toString(param1 : Int, param2 : Int) : String;
 	@:native("toString") @:overload static function _toString(param1 : Int) : String;
 	@:native("toString") @:overload static function _toString(param1 : Int) : String;
-	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Integer;
 	@:overload static function valueOf(param1 : Int) : Integer;
 	@:overload static function valueOf(param1 : Int) : Integer;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Integer;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Integer;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Integer;
 }
 }
 
 

+ 1 - 1
std/java/lang/Short.hx

@@ -50,8 +50,8 @@
 	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String) : java.types.Int16;
 	@:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String) : java.types.Int16;
 	@:overload static function reverseBytes(param1 : java.types.Int16) : java.types.Int16;
 	@:overload static function reverseBytes(param1 : java.types.Int16) : java.types.Int16;
 	@:native("toString") @:overload static function _toString(param1 : java.types.Int16) : String;
 	@:native("toString") @:overload static function _toString(param1 : java.types.Int16) : String;
-	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Short;
 	@:overload static function valueOf(param1 : java.types.Int16) : Short;
 	@:overload static function valueOf(param1 : java.types.Int16) : Short;
+	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Short;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Short;
 	@:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Short;
 }
 }
 
 

+ 9 - 2
std/lua/_std/String.hx

@@ -27,7 +27,7 @@ import lua.NativeStringTools;
 
 
 @:coreApi
 @:coreApi
 class String {
 class String {
-	static var __oldindex : Table<Dynamic,Dynamic>;
+	static var __oldindex : String->String->Dynamic;
 	public var length(default,null) : Int;
 	public var length(default,null) : Int;
 
 
 
 
@@ -37,7 +37,14 @@ class String {
 	static function __index(s:Dynamic, k:Dynamic) : Dynamic {
 	static function __index(s:Dynamic, k:Dynamic) : Dynamic {
 		if (k == "length") return NativeStringTools.len(s);
 		if (k == "length") return NativeStringTools.len(s);
 		else if (Reflect.hasField(untyped String.prototype, k)) return untyped String.prototype[k];
 		else if (Reflect.hasField(untyped String.prototype, k)) return untyped String.prototype[k];
-		else if (__oldindex != null) return  __oldindex[k];
+		else if (__oldindex != null) {
+			if (Lua.type(__oldindex) == "function"){
+				return  __oldindex(s,k);
+			} else if (Lua.type(__oldindex) == "table"){
+				return  untyped __oldindex[k];
+			}
+			return null;
+		}
 		else return null;
 		else return null;
 	}
 	}
 
 

+ 4 - 4
std/php7/_std/sys/db/Mysql.hx

@@ -63,7 +63,7 @@ private class MysqlConnection implements Connection {
 
 
 	public function request( s : String ) : ResultSet {
 	public function request( s : String ) : ResultSet {
 		var result = db.query(s);
 		var result = db.query(s);
-		if (result == false) throw 'Failed to perform db query';
+		if (result == false) throw 'Failed to perform db query: ' + db.error;
 		if (result == true) return null;
 		if (result == true) return null;
 
 
 		return new MysqlResultSet(result);
 		return new MysqlResultSet(result);
@@ -103,17 +103,17 @@ private class MysqlConnection implements Connection {
 
 
 	public function startTransaction() : Void {
 	public function startTransaction() : Void {
 		var success = db.begin_transaction();
 		var success = db.begin_transaction();
-		if (!success) throw 'Failed to start transaction';
+		if (!success) throw 'Failed to start transaction: ' + db.error;
 	}
 	}
 
 
 	public function commit() : Void {
 	public function commit() : Void {
 		var success = db.commit();
 		var success = db.commit();
-		if (!success) throw 'Failed to commit transaction';
+		if (!success) throw 'Failed to commit transaction: ' + db.error;
 	}
 	}
 
 
 	public function rollback() : Void {
 	public function rollback() : Void {
 		var success = db.rollback();
 		var success = db.rollback();
-		if (!success) throw 'Failed to rollback transaction';
+		if (!success) throw 'Failed to rollback transaction: ' + db.error;
 	}
 	}
 
 
 }
 }

+ 1 - 1
tests/display/src/File.hx

@@ -32,7 +32,7 @@ class File {
 			var start = lines[mid];
 			var start = lines[mid];
 			return
 			return
 				if (mid == min)
 				if (mid == min)
-					{line: mid, pos: pos - start};
+					{line: mid, pos: pos - start + 1};
 				else if (start > pos)
 				else if (start > pos)
 					loop(min, mid);
 					loop(min, mid);
 				else
 				else

+ 22 - 0
tests/display/src/cases/Issue6381.hx

@@ -0,0 +1,22 @@
+package cases;
+
+class Issue6381 extends DisplayTestCase {
+	/**
+	import haxe.ds.Option;
+
+	class Main {
+		public static function main() {
+			switch (Some(Some("foo"))) {
+				case Some({-1-}in{-2-}ner{-3-} = Some(_)):
+					{-4-}inner{-5-};
+				case _:
+			}
+		}
+	}
+	**/
+	function test() {
+		eq("haxe.ds.Option<String>", type(pos(2)));
+		eq(range(1, 3), position(pos(2)));
+		eq(range(4, 5), usage(pos(2))[0]);
+	}
+}

+ 20 - 0
tests/display/src/cases/Issue6396.hx

@@ -0,0 +1,20 @@
+package cases;
+
+class Issue6396 extends DisplayTestCase {
+	/**
+	class Main {
+		public static function main() {}
+
+		macro function foo() {
+			var {-1-}name{-2-} = "name";
+			return macro {
+				$na{-3-}me;
+			}
+		}
+	}
+	**/
+	function test() {
+		eq(range(1, 2), position(pos(2)));
+		eq("String", type(pos(2)));
+	}
+}

+ 24 - 0
tests/display/src/cases/Toplevel.hx

@@ -163,6 +163,30 @@ class Toplevel extends DisplayTestCase {
 		eq(true, hasToplevel(toplevel(pos(2)), "type", "FieldT2"));
 		eq(true, hasToplevel(toplevel(pos(2)), "type", "FieldT2"));
 	}
 	}
 
 
+	/**
+	import cases.Toplevel.E.a;
+
+	enum E {
+		a;
+	}
+
+	class Main {
+		static var a:Int;
+		function new(a) {
+			{-1-}
+		}
+
+		static function main() {
+		}
+	}
+	**/
+	function testDuplicates() {
+		var toplevels = toplevel(pos(1));
+		toplevels = toplevels.filter(function(t) return t.name == "a");
+		eq(1, toplevels.length);
+		eq("local", toplevels[0].kind);
+	}
+
 	public static function hasToplevel(a:Array<ToplevelElement>, kind:String, name:String):Bool {
 	public static function hasToplevel(a:Array<ToplevelElement>, kind:String, name:String):Bool {
 		return a.exists(function(t) return t.kind == kind && t.name == name);
 		return a.exists(function(t) return t.kind == kind && t.name == name);
 	}
 	}

+ 1 - 1
tests/misc/projects/Issue1138/compile3-fail.hxml.stderr

@@ -1 +1 @@
-src1/D.hx:3: characters 8-16 : Int has no field triple
+src1/D.hx:3: characters 9-17 : Int has no field triple

+ 1 - 1
tests/misc/projects/Issue1138/compile4-fail.hxml.stderr

@@ -1 +1 @@
-$$normPath(::cwd::/src3/import.hx):1: characters 0-14 : Only import and using is allowed in import.hx files
+$$normPath(::cwd::/src3/import.hx):1: characters 1-15 : Only import and using is allowed in import.hx files

+ 2 - 2
tests/misc/projects/Issue1310/compile1-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main1.hx:17: characters 12-17 : Array<Int> should be ToString.S
-Main1.hx:17: characters 12-17 : For function argument ''
+Main1.hx:17: characters 13-18 : Array<Int> should be ToString.S
+Main1.hx:17: characters 13-18 : For function argument ''

+ 1 - 1
tests/misc/projects/Issue1968/compile.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):4: characters 18-61</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):4: characters 19-62</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2087/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:3: characters 2-6 : Type not found : haxe.Resauce
+Main.hx:3: characters 3-7 : Type not found : haxe.Resauce

+ 2 - 2
tests/misc/projects/Issue2148/compile1-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main1.hx:7: characters 21-24 : Unknown identifier : foo
-Main1.hx:7: characters 21-24 : For function argument 'i'
+Main1.hx:7: characters 22-25 : Unknown identifier : foo
+Main1.hx:7: characters 22-25 : For function argument 'i'

+ 2 - 2
tests/misc/projects/Issue2232/compile1-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main1.hx:4: characters 6-7 : Float should be Int
-Main1.hx:4: characters 6-7 : For optional function argument 'x'
+Main1.hx:4: characters 7-8 : Float should be Int
+Main1.hx:4: characters 7-8 : For optional function argument 'x'

+ 1 - 1
tests/misc/projects/Issue2232/compile2-fail.hxml.stderr

@@ -1 +1 @@
-Main2.hx:4: characters 2-8 : Cannot skip non-nullable argument x
+Main2.hx:4: characters 3-9 : Cannot skip non-nullable argument x

+ 10 - 10
tests/misc/projects/Issue2508/compile.hxml.stderr

@@ -1,10 +1,10 @@
-Main.hx:15: characters 3-13 : Warning : This case is unused
-Main.hx:20: characters 3-12 : Warning : This case is unused
-Main.hx:21: characters 3-13 : Warning : This case is unused
-Main.hx:26: characters 5-10 : Warning : This pattern is unused
-Main.hx:32: characters 6-17 : Warning : This pattern is unused
-Main.hx:44: characters 3-30 : Warning : This case is unused
-Main.hx:50: characters 3-17 : Warning : This case is unused
-Main.hx:55: characters 3-13 : Warning : This case is unused
-Main.hx:60: characters 3-14 : Warning : This case is unused
-Main.hx:66: characters 8-14 : Warning : This pattern is unused
+Main.hx:15: characters 4-14 : Warning : This case is unused
+Main.hx:20: characters 4-13 : Warning : This case is unused
+Main.hx:21: characters 4-14 : Warning : This case is unused
+Main.hx:26: characters 6-11 : Warning : This pattern is unused
+Main.hx:32: characters 7-18 : Warning : This pattern is unused
+Main.hx:44: characters 4-31 : Warning : This case is unused
+Main.hx:50: characters 4-18 : Warning : This case is unused
+Main.hx:55: characters 4-14 : Warning : This case is unused
+Main.hx:60: characters 4-15 : Warning : This case is unused
+Main.hx:66: characters 9-15 : Warning : This pattern is unused

+ 1 - 1
tests/misc/projects/Issue2538/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:7: characters 12-24 : Cannot use Void as value
+Main.hx:7: characters 13-25 : Cannot use Void as value

+ 1 - 1
tests/misc/projects/Issue2991/compile.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):6: characters 12-13</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):6: characters 13-14</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2993/compile.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):2: characters 15-18</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):2: characters 16-19</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2995/position.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):2: characters 4-21</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):2: characters 5-22</pos>
 </list>
 </list>

+ 2 - 2
tests/misc/projects/Issue2995/usage.hxml.stderr

@@ -1,4 +1,4 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):5: characters 16-26</pos>
-<pos>$$normPath(::cwd::/Main.hx, true):9: characters 8-18</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):5: characters 17-27</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):9: characters 9-19</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2996/compile1.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/A.hx, true):1: characters 0-21</pos>
+<pos>$$normPath(::cwd::/A.hx, true):1: characters 1-22</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2996/compile2.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/pack/B.hx, true):3: characters 0-10</pos>
+<pos>$$normPath(::cwd::/pack/B.hx, true):3: characters 1-11</pos>
 </list>
 </list>

+ 1 - 1
tests/misc/projects/Issue2997/compile1.hxml.stderr

@@ -1,3 +1,3 @@
 <list>
 <list>
-<pos>$$normPath(::cwd::/Main.hx, true):2: characters 4-14</pos>
+<pos>$$normPath(::cwd::/Main.hx, true):2: characters 5-15</pos>
 </list>
 </list>

+ 3 - 3
tests/misc/projects/Issue3192/compile1-fail.hxml.stderr

@@ -1,3 +1,3 @@
-Main1.hx:3: characters 18-32 : { b : Int, a : Int } has extra field b
-Main1.hx:3: characters 2-33 : { b : Int, a : Int } should be { a : Int }
-Main1.hx:3: characters 2-33 : { b : Int, a : Int } has extra field b
+Main1.hx:3: characters 19-33 : { b : Int, a : Int } has extra field b
+Main1.hx:3: characters 3-34 : { b : Int, a : Int } should be { a : Int }
+Main1.hx:3: characters 3-34 : { b : Int, a : Int } has extra field b

+ 1 - 1
tests/misc/projects/Issue3238/default-value-fail.hxml.stderr

@@ -1 +1 @@
-DefaultValue.hx:2: characters 44-48 : Rest argument cannot have default value
+DefaultValue.hx:2: characters 45-49 : Rest argument cannot have default value

+ 1 - 1
tests/misc/projects/Issue3238/non-extern-fail.hxml.stderr

@@ -1 +1 @@
-NonExtern.hx:2: characters 22-23 : Rest argument are only supported for extern methods
+NonExtern.hx:2: characters 23-24 : Rest argument are only supported for extern methods

+ 1 - 1
tests/misc/projects/Issue3238/not-last-fail.hxml.stderr

@@ -1 +1 @@
-NotLast.hx:2: characters 15-16 : Rest should only be used for the last function argument
+NotLast.hx:2: characters 16-17 : Rest should only be used for the last function argument

+ 1 - 1
tests/misc/projects/Issue3238/optional-fail.hxml.stderr

@@ -1 +1 @@
-Optional.hx:2: characters 16-17 : Rest argument cannot be optional
+Optional.hx:2: characters 17-18 : Rest argument cannot be optional

+ 1 - 1
tests/misc/projects/Issue3361/compile1-fail.hxml.stderr

@@ -1,4 +1,4 @@
 Main.hx:5: lines 5-8 : Field v has different type than in I
 Main.hx:5: lines 5-8 : Field v has different type than in I
-Main.hx:2: characters 8-28 : Interface field is defined here
+Main.hx:2: characters 9-29 : Interface field is defined here
 Main.hx:5: lines 5-8 : String -> Void should be Dynamic -> Void
 Main.hx:5: lines 5-8 : String -> Void should be Dynamic -> Void
 Main.hx:5: lines 5-8 : String should be Dynamic
 Main.hx:5: lines 5-8 : String should be Dynamic

+ 4 - 4
tests/misc/projects/Issue3361/compile2-fail.hxml.stderr

@@ -1,4 +1,4 @@
-Main2.hx:6: characters 16-45 : Field f has different type than in I
-Main2.hx:2: characters 16-43 : Interface field is defined here
-Main2.hx:6: characters 16-45 : s : String -> Void should be d : Dynamic -> Void
-Main2.hx:6: characters 16-45 : String should be Dynamic
+Main2.hx:6: characters 17-46 : Field f has different type than in I
+Main2.hx:2: characters 17-44 : Interface field is defined here
+Main2.hx:6: characters 17-46 : s : String -> Void should be d : Dynamic -> Void
+Main2.hx:6: characters 17-46 : String should be Dynamic

+ 3 - 3
tests/misc/projects/Issue3417/compile-fail.hxml.stderr

@@ -1,3 +1,3 @@
-Main.hx:6: characters 11-26 : Field f has different type than in I
-Main.hx:2: characters 4-27 : Interface field is defined here
-Main.hx:6: characters 11-26 : Different number of function arguments
+Main.hx:6: characters 12-27 : Field f has different type than in I
+Main.hx:2: characters 5-28 : Interface field is defined here
+Main.hx:6: characters 12-27 : Different number of function arguments

+ 1 - 1
tests/misc/projects/Issue3457/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:1: characters 0-14 : Type aliases must start with an uppercase letter
+Main.hx:1: characters 1-15 : Type aliases must start with an uppercase letter

+ 1 - 1
tests/misc/projects/Issue3621/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main1.hx:11: characters 16-17 : Unmatched patterns: E.C
+Main1.hx:11: characters 17-18 : Unmatched patterns: E.C

+ 3 - 3
tests/misc/projects/Issue3678/compile-fail.hxml.stderr

@@ -1,3 +1,3 @@
-Main.hx:3: characters 17-18 : expression expected after =
-Main.hx:3: characters 19-69 : Unnamed lvalue functions are not supported
-Main.hx:4: characters 8-12 : Unknown identifier : func
+Main.hx:3: characters 18-19 : expression expected after =
+Main.hx:3: characters 20-70 : Unnamed lvalue functions are not supported
+Main.hx:4: characters 9-13 : Unknown identifier : func

+ 2 - 2
tests/misc/projects/Issue3699/compile-var-fail.hxml.stderr

@@ -1,2 +1,2 @@
-MainVar.hx:3: characters 10-11 : expression expected after =
-MainVar.hx:3: characters 12-13 : Unexpected ;
+MainVar.hx:3: characters 11-12 : expression expected after =
+MainVar.hx:3: characters 13-14 : Unexpected ;

+ 1 - 1
tests/misc/projects/Issue3710/compile-1-fail.hxml.stderr

@@ -1 +1 @@
-Main1.hx:3: characters 8-22 : Invalid number of type parameters for A
+Main1.hx:3: characters 9-23 : Invalid number of type parameters for A

+ 1 - 1
tests/misc/projects/Issue3710/compile-2-fail.hxml.stderr

@@ -1 +1 @@
-Main2.hx:3: characters 8-17 : Invalid number of type parameters for A
+Main2.hx:3: characters 9-18 : Invalid number of type parameters for A

+ 1 - 1
tests/misc/projects/Issue3714/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:7: characters 8-11 : Cannot access private field a
+Main.hx:7: characters 9-12 : Cannot access private field a

+ 1 - 1
tests/misc/projects/Issue3726/compile-1-fail.hxml.stderr

@@ -1 +1 @@
-Main1.hx:3: characters 4-36 : Method get_test is no valid accessor for test because it is not static
+Main1.hx:3: characters 5-37 : Method get_test is no valid accessor for test because it is not static

+ 1 - 1
tests/misc/projects/Issue3726/compile-2-fail.hxml.stderr

@@ -1 +1 @@
-Main2.hx:3: characters 11-43 : Method get_test is no valid accessor for test because it is static
+Main2.hx:3: characters 12-44 : Method get_test is no valid accessor for test because it is static

+ 2 - 2
tests/misc/projects/Issue3781/compile-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main.hx:12: characters 8-10 : Constraint check failure for E1.T
-Main.hx:12: characters 8-10 : Main.T should be String
+Main.hx:12: characters 9-11 : Constraint check failure for E1.T
+Main.hx:12: characters 9-11 : Main.T should be String

+ 1 - 1
tests/misc/projects/Issue3783/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:3: characters 2-8 : Cannot access this or other member field in variable initialization
+Main.hx:3: characters 3-9 : Cannot access this or other member field in variable initialization

+ 1 - 1
tests/misc/projects/Issue3802/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:3: characters 2-8 : Not enough arguments, expected i:Int, s:String
+Main.hx:3: characters 3-9 : Not enough arguments, expected i:Int, s:String

+ 1 - 1
tests/misc/projects/Issue3830/compile-fail.hxml.stderr

@@ -1 +1 @@
-MainFail.hx:3: characters 0-63 : @:coreType abstracts cannot be @:callable
+MainFail.hx:3: characters 1-64 : @:coreType abstracts cannot be @:callable

+ 2 - 2
tests/misc/projects/Issue3975/compile-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main.hx:4: characters 2-54 : Array<String> should be { pop : Void -> Void }
-Main.hx:4: characters 2-54 : Field pop is method but should be (get,never)
+Main.hx:4: characters 3-55 : Array<String> should be { pop : Void -> Void }
+Main.hx:4: characters 3-55 : Field pop is method but should be (get,never)

+ 1 - 1
tests/misc/projects/Issue4114/compile1-fail.hxml.stderr

@@ -1 +1 @@
-Main1.hx:2: characters 31-34 : Missing return: String
+Main1.hx:2: characters 32-35 : Missing return: String

+ 1 - 1
tests/misc/projects/Issue4247/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:8: characters 3-21 : Incompatible pattern
+Main.hx:8: characters 4-22 : Incompatible pattern

+ 5 - 5
tests/misc/projects/Issue4250/compile-fail.hxml.stderr

@@ -1,5 +1,5 @@
-Main.hx:11: characters 8-30 : SomeNode should be Node
-Main.hx:11: characters 8-30 : SomeNode should be { parent : Node }
-Main.hx:11: characters 8-30 : Invalid type for field parent :
-Main.hx:11: characters 8-30 : SomeNode should be Node
-Main.hx:11: characters 8-30 : SomeNode should be { parent : Node }
+Main.hx:11: characters 9-31 : SomeNode should be Node
+Main.hx:11: characters 9-31 : SomeNode should be { parent : Node }
+Main.hx:11: characters 9-31 : Invalid type for field parent :
+Main.hx:11: characters 9-31 : SomeNode should be Node
+Main.hx:11: characters 9-31 : SomeNode should be { parent : Node }

+ 1 - 1
tests/misc/projects/Issue4293/compile-abstract-fail.hxml.stderr

@@ -1 +1 @@
-OnAbstract.hx:1: characters 23-24 : Duplicate type parameter name: T
+OnAbstract.hx:1: characters 24-25 : Duplicate type parameter name: T

+ 1 - 1
tests/misc/projects/Issue4293/compile-class-fail.hxml.stderr

@@ -1 +1 @@
-OnClass.hx:1: characters 17-18 : Duplicate type parameter name: T
+OnClass.hx:1: characters 18-19 : Duplicate type parameter name: T

+ 1 - 1
tests/misc/projects/Issue4293/compile-enum-ctor-fail.hxml.stderr

@@ -1 +1 @@
-OnEnumCtor.hx:2: characters 6-7 : Duplicate type parameter name: T
+OnEnumCtor.hx:2: characters 7-8 : Duplicate type parameter name: T

+ 1 - 1
tests/misc/projects/Issue4293/compile-enum-fail.hxml.stderr

@@ -1 +1 @@
-OnEnum.hx:1: characters 15-16 : Duplicate type parameter name: T
+OnEnum.hx:1: characters 16-17 : Duplicate type parameter name: T

+ 1 - 1
tests/misc/projects/Issue4293/compile-field-fail.hxml.stderr

@@ -1 +1 @@
-OnField.hx:2: characters 25-26 : Duplicate type parameter name: T
+OnField.hx:2: characters 26-27 : Duplicate type parameter name: T

+ 1 - 1
tests/misc/projects/Issue4293/compile-typedef-fail.hxml.stderr

@@ -1 +1 @@
-OnTypedef.hx:1: characters 21-22 : Duplicate type parameter name: T
+OnTypedef.hx:1: characters 22-23 : Duplicate type parameter name: T

+ 2 - 2
tests/misc/projects/Issue4364/compile-fail.hxml.stderr

@@ -1,2 +1,2 @@
-Main.hx:22: characters 14-18 : Constraint check failure for G.T
-Main.hx:22: characters 14-18 : A should be haxe.Constructible<Void -> Void>
+Main.hx:22: characters 15-19 : Constraint check failure for G.T
+Main.hx:22: characters 15-19 : A should be haxe.Constructible<Void -> Void>

+ 1 - 1
tests/misc/projects/Issue4370/compile-fail.hxml.stderr

@@ -1 +1 @@
-Test.hx:9: characters 15-18 : Int should be Bool
+Test.hx:9: characters 16-19 : Int should be Bool

+ 1 - 1
tests/misc/projects/Issue4378/compile-fail.hxml.stderr

@@ -1,4 +1,4 @@
 Main.hx:5: lines 5-7 : Field test has different type than in I
 Main.hx:5: lines 5-7 : Field test has different type than in I
-Main.hx:16: characters 1-31 : Interface field is defined here
+Main.hx:16: characters 2-32 : Interface field is defined here
 Main.hx:5: lines 5-7 : s : String -> Void should be s : Dynamic -> Void
 Main.hx:5: lines 5-7 : s : String -> Void should be s : Dynamic -> Void
 Main.hx:5: lines 5-7 : String should be Dynamic
 Main.hx:5: lines 5-7 : String should be Dynamic

+ 3 - 3
tests/misc/projects/Issue4448/compile1-fail.hxml.stderr

@@ -1,3 +1,3 @@
-Main1.hx:11: characters 8-9 : Cannot access non-static field f from static method
-Main1.hx:12: characters 8-9 : Cannot access non-static field v from static method
-Main1.hx:13: characters 8-10 : Cannot access non-static field v2 from static method
+Main1.hx:11: characters 9-10 : Cannot access non-static field f from static method
+Main1.hx:12: characters 9-10 : Cannot access non-static field v from static method
+Main1.hx:13: characters 9-11 : Cannot access non-static field v2 from static method

+ 1 - 1
tests/misc/projects/Issue4466/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:4: characters 16-17 : Local variable a used without being initialized
+Main.hx:4: characters 17-18 : Local variable a used without being initialized

+ 4 - 4
tests/misc/projects/Issue4540/compile-fail.hxml.stderr

@@ -1,4 +1,4 @@
-Main.hx:3: characters 35-54 : c : { test : String } -> Void should be Null<js.PromiseCallback<Int, Void>>
-Main.hx:3: characters 35-54 : c : { test : String } -> Void should be js.PromiseCallback<Int, Void>
-Main.hx:3: characters 35-54 : c : { test : String } -> Void should be haxe.extern.EitherType<Int -> Void, Int -> js.Promise<Void>>
-Main.hx:3: characters 35-54 : For function argument 'fulfillCallback'
+Main.hx:3: characters 36-55 : c : { test : String } -> Void should be Null<js.PromiseCallback<Int, Void>>
+Main.hx:3: characters 36-55 : c : { test : String } -> Void should be js.PromiseCallback<Int, Void>
+Main.hx:3: characters 36-55 : c : { test : String } -> Void should be haxe.extern.EitherType<Int -> Void, Int -> js.Promise<Void>>
+Main.hx:3: characters 36-55 : For function argument 'fulfillCallback'

+ 1 - 1
tests/misc/projects/Issue4671/compile1-fail.hxml.stderr

@@ -1 +1 @@
-Main1.hx:1: characters 0-29 : Recursive class
+Main1.hx:1: characters 1-30 : Recursive class

+ 1 - 1
tests/misc/projects/Issue4671/compile2-fail.hxml.stderr

@@ -1 +1 @@
-Main2.hx:1: characters 0-21 : Recursive class
+Main2.hx:1: characters 1-22 : Recursive class

+ 1 - 1
tests/misc/projects/Issue4689/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:10: characters 24-25 : Unmatched patterns: B
+Main.hx:10: characters 25-26 : Unmatched patterns: B

+ 18 - 18
tests/misc/projects/Issue4720/compile.hxml.stderr

@@ -1,18 +1,18 @@
-Main.hx:8: characters 8-14 : Warning : Usage of this typedef is deprecated
-Main.hx:9: characters 8-18 : Warning : Usage of this typedef is deprecated
-Main.hx:10: characters 8-13 : Warning : Usage of this typedef is deprecated
-Main.hx:19: characters 8-18 : Warning : Usage of this typedef is deprecated
-Main.hx:4: characters 8-15 : Warning : Usage of this class is deprecated
-Main.hx:5: characters 8-19 : Warning : Usage of this class is deprecated
-Main.hx:6: characters 8-14 : Warning : Usage of this enum is deprecated
-Main.hx:15: characters 8-21 : Warning : Usage of this class is deprecated
-Main.hx:16: characters 8-19 : Warning : Usage of this enum is deprecated
-Main.hx:17: characters 8-28 : Warning : Usage of this class is deprecated
-Main.hx:18: characters 8-20 : Warning : Usage of this class is deprecated
-Main.hx:20: characters 8-27 : Warning : Usage of this class is deprecated
-Main.hx:23: characters 8-23 : Warning : Usage of this field is deprecated
-Main.hx:24: characters 8-22 : Warning : Usage of this field is deprecated
-Main.hx:25: characters 8-26 : Warning : Usage of this field is deprecated
-Main.hx:26: characters 16-34 : Warning : Usage of this field is deprecated
-Main.hx:27: characters 8-24 : Warning : Usage of this field is deprecated
-Main.hx:28: characters 16-32 : Warning : Usage of this field is deprecated
+Main.hx:8: characters 9-15 : Warning : Usage of this typedef is deprecated
+Main.hx:9: characters 9-19 : Warning : Usage of this typedef is deprecated
+Main.hx:10: characters 9-14 : Warning : Usage of this typedef is deprecated
+Main.hx:19: characters 9-19 : Warning : Usage of this typedef is deprecated
+Main.hx:4: characters 9-16 : Warning : Usage of this class is deprecated
+Main.hx:5: characters 9-20 : Warning : Usage of this class is deprecated
+Main.hx:6: characters 9-15 : Warning : Usage of this enum is deprecated
+Main.hx:15: characters 9-22 : Warning : Usage of this class is deprecated
+Main.hx:16: characters 9-20 : Warning : Usage of this enum is deprecated
+Main.hx:17: characters 9-29 : Warning : Usage of this class is deprecated
+Main.hx:18: characters 9-21 : Warning : Usage of this class is deprecated
+Main.hx:20: characters 9-28 : Warning : Usage of this class is deprecated
+Main.hx:23: characters 9-24 : Warning : Usage of this field is deprecated
+Main.hx:24: characters 9-23 : Warning : Usage of this field is deprecated
+Main.hx:25: characters 9-27 : Warning : Usage of this field is deprecated
+Main.hx:26: characters 17-35 : Warning : Usage of this field is deprecated
+Main.hx:27: characters 9-25 : Warning : Usage of this field is deprecated
+Main.hx:28: characters 17-33 : Warning : Usage of this field is deprecated

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