Jelajahi Sumber

Fix false-positive of "modify this in non-inline"
fixes #8530

Aleksandr Kuzmenko 6 tahun lalu
induk
melakukan
2f802e519b

+ 2 - 1
src/typing/calls.ml

@@ -60,7 +60,8 @@ let make_call ctx e params t ?(force_inline=false) p =
 		(match cl, ctx.curclass.cl_kind, params with
 			| Some c, KAbstractImpl _, { eexpr = TLocal { v_meta = v_meta } } :: _ when c == ctx.curclass ->
 				if
-					has_meta Meta.This v_meta
+					f.cf_name <> "_new"
+					&& has_meta Meta.This v_meta
 					&& not (assign_to_this_is_allowed ctx)
 					&& has_class_field_flag f CfModifiesThis
 				then

+ 13 - 0
tests/misc/projects/Issue8530/Main.hx

@@ -0,0 +1,13 @@
+class Main {
+	public static function main():Void {}
+}
+
+abstract Abstr(Int) {
+	inline function new(v) {
+		this = v;
+	}
+
+	public function test() {
+		new Abstr(this);
+	}
+}

+ 1 - 0
tests/misc/projects/Issue8530/compile.hxml

@@ -0,0 +1 @@
+-main Main