Forráskód Böngészése

[typer] fix `is_abstract_this_access` logic

closes #9060
Aleksandr Kuzmenko 5 éve
szülő
commit
597fdd3d6f
3 módosított fájl, 41 hozzáadás és 1 törlés
  1. 1 0
      extra/CHANGES.txt
  2. 1 1
      src/typing/fields.ml
  3. 39 0
      tests/unit/src/unit/issues/Issue9060.hx

+ 1 - 0
extra/CHANGES.txt

@@ -5,6 +5,7 @@
 	all : emit an error on an attempt to modify abstract `this` through a chain of inlined calls in a non-inlined method (#9067)
 	all : fixed completion of target specific hx files without the common hx file (e.g. `Example.js.hx` with non-existent `Example.hx`) (#6435)
 	all : fixed inlining regression (#9058)
+	all : fixed invalid generation of static properties access in abstracts (#9060)
 	js : fixed startup exception in IE8 related to `Object.defineProperty` (#6918)
 
 

+ 1 - 1
src/typing/fields.ml

@@ -232,7 +232,7 @@ let field_access ctx mode f fmode t e p =
 		| AccCall ->
 			let m = (match mode with MSet -> "set_" | _ -> "get_") ^ f.cf_name in
 			let is_abstract_this_access () = match e.eexpr,ctx.curfun with
-				| TTypeExpr (TClassDecl ({cl_kind = KAbstractImpl _} as c)),(FunMemberAbstract | FunMemberAbstractLocal) ->
+				| TTypeExpr (TClassDecl ({cl_kind = KAbstractImpl _} as c)),(FunMemberAbstract | FunMemberAbstractLocal) when Meta.has Meta.Impl f.cf_meta  ->
 					c == ctx.curclass
 				| _ ->
 					false

+ 39 - 0
tests/unit/src/unit/issues/Issue9060.hx

@@ -0,0 +1,39 @@
+package unit.issues;
+
+import unit.Test;
+
+class Issue9060 extends Test {
+	function test() {
+		var i64 = new Int64(new Impl());
+		eq("helloworld", i64.prefixDecrement());
+	}
+}
+
+private class Impl {
+	public inline function new() {}
+}
+
+private abstract Int64(Impl) from Impl {
+	static public var MIN(get, never):Int64;
+
+	static function get_MIN():Int64 {
+		return new Int64(new Impl());
+	}
+
+	public function new(value:Impl) {
+		this = value;
+	}
+
+	inline function equal(b:Int64):Bool {
+		return this != null;
+	}
+
+	inline public function prefixDecrement() {
+		var s = "";
+		if (MIN.equal(new Int64(this))) {
+			s += "hello";
+		}
+		s += "world";
+		return s;
+	}
+}