فهرست منبع

(Flash9) use real field name to check for overrides (closes #2785)

Simon Krajewski 11 سال پیش
والد
کامیت
00ba793127
2فایلهای تغییر یافته به همراه37 افزوده شده و 3 حذف شده
  1. 3 3
      genswf9.ml
  2. 34 0
      tests/unit/issues/Issue2785.hx

+ 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 f.cf_name; (* use real field name to check for overrides (issue #2785) *)
 				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;

+ 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
+}