Explorar el Código

Merge remote-tracking branch 'remotes/upstream/development' into bridgeProperties

杨博 hace 11 años
padre
commit
aa1a9d2e6e

+ 1 - 1
codegen.ml

@@ -358,7 +358,7 @@ let rec build_generic ctx c p tl =
 						begin match f.cf_kind with
 							| Method _ when not c.cl_interface && not c.cl_extern ->
 								display_error ctx (Printf.sprintf "Field %s has no expression (possible typing order issue)" f.cf_name) f.cf_pos;
-								error (Printf.sprintf "While building %s" (s_type_path cg.cl_path)) p;
+								display_error ctx (Printf.sprintf "While building %s" (s_type_path cg.cl_path)) p;
 							| _ ->
 								()
 						end

+ 3 - 3
genswf9.ml

@@ -2016,7 +2016,7 @@ let generate_field_kind ctx f c stat =
 			Some (HFMethod {
 				hlm_type = m;
 				hlm_final = stat || (Meta.has Meta.Final f.cf_meta);
-				hlm_override = not stat && loop c name;
+				hlm_override = not stat && (loop c name || loop c f.cf_name);
 				hlm_kind = kind;
 			})
 		);
@@ -2044,7 +2044,7 @@ let generate_field_kind ctx f c stat =
 			hlv_value = HVNone;
 			hlv_const = false;
 		})
-		
+
 let check_constructor ctx c f =
 	(*
 		check that we don't assign a super Float var before we call super() : will result in NaN
@@ -2061,7 +2061,7 @@ let check_constructor ctx c f =
 		loop f.tf_expr
 	with Exit ->
 		()
-		
+
 let generate_class ctx c =
 	let name = type_path ctx c.cl_path in
 	ctx.cur_class <- c;

+ 1 - 1
main.ml

@@ -930,7 +930,7 @@ try
 	let interp = ref false in
 	let swf_version = ref false in
 	Common.define_value com Define.HaxeVer (float_repres (float_of_int version /. 1000.));
-	Common.define_value com Define.HxcppApiLevel "311";
+	Common.define_value com Define.HxcppApiLevel "312";
 	Common.raw_define com "haxe3";
 	Common.define_value com Define.Dce "std";
 	com.warning <- (fun msg p -> message ctx ("Warning : " ^ msg) p);

+ 4 - 2
optimizer.ml

@@ -1242,8 +1242,10 @@ let inline_constructors ctx e =
 			end
 		| TField({eexpr = TLocal v}, (FInstance(_, {cf_kind = Var _; cf_name = s}) | FAnon({cf_kind = Var _; cf_name = s}))) ->
 			()
-		| TArray ({eexpr = TLocal v},{eexpr = TConst (TInt i)}) ->
-			()
+		| TArray ({eexpr = TLocal v},{eexpr = TConst (TInt i)}) when v.v_id < 0 ->
+			let (_,_,fields,_,_) = PMap.find (-v.v_id) !vars in
+			let i = Int32.to_int i in
+			if i < 0 || i >= List.length fields then cancel v
 		| TBinop((OpAssign | OpAssignOp _),e1,e2) ->
 			begin match e1.eexpr with
 				| TArray ({eexpr = TLocal v},{eexpr = TConst (TInt i)}) when v.v_id < 0 && not (is_valid_field v (Int32.to_string i)) ->

+ 3 - 3
tests/RunTravis.hx

@@ -428,8 +428,8 @@ class RunTravis {
 				testFlambe();
 				testHxTemplo();
 				testMUnit();
-				testOpenflSamples();
-				testFlixelDemos();
+				//testOpenflSamples();
+				//testFlixelDemos();
 			case t:
 				throw "unknown target: " + t;
 		}
@@ -508,7 +508,7 @@ class RunTravis {
 		var path = getHaxelibPath("openfl-samples");
 		var old = Sys.getEnv("pwd");
 		Sys.putEnv("pwd", path);
-		//parseTravisFile(haxe.io.Path.join([path, ".travis.yml"]), true);
+		parseTravisFile(haxe.io.Path.join([path, ".travis.yml"]), true);
 		if (old != null) {
 			Sys.putEnv("pwd", old);
 		}

+ 18 - 0
tests/optimization/src/Test.hx

@@ -110,4 +110,22 @@ class Test {
 		var a = [1, 2];
 		var b = a.length;
 	}
+
+	@:js('
+		var a = [1,2];
+		a[-1];
+	')
+	static function testArrayInlineCancelNegative() {
+		var a = [1, 2];
+		a[-1];
+	}
+
+	@:js('
+		var a = [1,2];
+		a[2];
+	')
+	static function testArrayInlineCancelExceeds() {
+		var a = [1, 2];
+		a[2];
+	}
 }

+ 34 - 0
tests/unit/issues/Issue2785.hx

@@ -0,0 +1,34 @@
+package unit.issues;
+import unit.Test;
+
+private class Base {
+	public function new() {}
+
+	@:extern
+	public var foo(default, never):Int;
+
+	@:getter(foo)
+	@:keep
+	public function get_foo() {
+		return 1;
+	}
+}
+
+private class Child extends Base {
+	@:getter(foo)
+	override public function get_foo() {
+		return 2;
+	}
+}
+
+class Issue2785 extends Test {
+	#if flash
+	function test() {
+		var base = new Base();
+		eq(1, base.foo);
+
+		var child = new Child();
+		eq(2, child.foo);
+	}
+	#end
+}

+ 17 - 0
tests/unit/issues/Issue2999.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+class Issue2999 extends Test {
+	function test1() {
+		var a = [1, 2];
+		eq(1, a[0]);
+		eq(2, a[1]);
+		a[-1];
+	}
+
+	function test2() {
+		var a = [1, 2];
+		eq(1, a[0]);
+		eq(2, a[1]);
+		a[2];
+	}
+}

+ 25 - 0
tests/unit/issues/Issue3005.hx

@@ -0,0 +1,25 @@
+package unit.issues;
+
+@:generic
+private class A<T> {
+    public function new() {}
+    private function foo() {
+		var b = new B<String>();
+		b.foo();
+	}
+}
+
+@:generic
+private class B<T> {
+	public function new() {}
+	@:allow(unit.issues.A)
+	private function foo() {}
+}
+
+class Issue3005 extends Test {
+	@:access(unit.issues.A)
+	function test() {
+        var a = new A<String>();
+        a.foo();
+	}
+}

+ 5 - 3
typer.ml

@@ -237,6 +237,10 @@ let class_field ctx c pl name p =
 
 (* checks if we can access to a given class field using current context *)
 let rec can_access ctx ?(in_overload=false) c cf stat =
+	let c = match c.cl_kind with
+		| KGenericInstance(c,_) -> c
+		| _ -> c
+	in
 	if cf.cf_public then
 		true
 	else if not in_overload && ctx.com.config.pf_overload && Meta.has Meta.Overload cf.cf_meta then
@@ -3364,8 +3368,6 @@ and handle_display ctx e iscall p =
 		cf.cf_meta <- (Meta.Usage,[],p) :: cf.cf_meta;
 	in
 	match ctx.com.display with
-	| DMNone ->
-		assert false
 	| DMUsage | DMPosition ->
 		(* print_endline (s_expr (s_type (print_context())) e); *)
 		begin match e.eexpr with
@@ -3395,7 +3397,7 @@ and handle_display ctx e iscall p =
 		e
 	| DMToplevel ->
 		collect_toplevel_identifiers ctx;
-	| DMDefault ->
+	| DMDefault | DMNone ->
 		let opt_args args ret = TFun(List.map(fun (n,o,t) -> n,true,t) args,ret) in
 		let e = match e.eexpr with
 			| TField (e1,fa) ->