2
0
Эх сурвалжийг харах

[typer] only infer getter/setter types when dealing with actual getter/setter (#10936)

* [typer] only consider as getter/setter if matching property exists

* add tests for 10935
Rudy Ges 2 жил өмнө
parent
commit
e34df73af0

+ 3 - 1
src/typing/typeloadFields.ml

@@ -1250,7 +1250,9 @@ let setup_args_ret ctx cctx fctx name fd p =
 	let try_find_property_type () =
 		let name = String.sub name 4 (String.length name - 4) in
 		let cf = if fctx.is_static then PMap.find name c.cl_statics else PMap.find name c.cl_fields (* TODO: inheritance? *) in
-		cf.cf_type
+		match Lazy.force mk, cf.cf_kind with
+			| MKGetter, Var({v_read = AccCall}) | MKSetter, Var({v_write = AccCall}) -> cf.cf_type
+			| _ -> raise Not_found;
 	in
 	let maybe_use_property_type th check def =
 		if th = None && check() then

+ 6 - 0
tests/misc/projects/Issue10935/Main.hx

@@ -0,0 +1,6 @@
+class Main {
+	public var test:Int;
+	public function set_test(i:String) {
+		test = 42;
+	}
+}

+ 1 - 0
tests/misc/projects/Issue10935/build.hxml

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