Переглянути джерело

[analyzer] run on overloads too

closes #10405
Simon Krajewski 3 роки тому
батько
коміт
211572654b

+ 4 - 0
src/optimization/analyzer.ml

@@ -1089,6 +1089,10 @@ module Run = struct
 			cf.cf_expr <- Some e;
 		| _ -> ()
 
+	let run_on_field ctx config c cf =
+		run_on_field ctx config c cf;
+		List.iter (run_on_field ctx config c) cf.cf_overloads
+
 	let run_on_class ctx config c =
 		let config = update_config_from_meta ctx.Typecore.com config c.cl_meta in
 		let process_field stat cf = match cf.cf_kind with

+ 17 - 0
tests/unit/src/unit/issues/Issue10405.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+import utest.Assert;
+
+class Issue10405 extends Test {
+	#if jvm
+	public overload function onEvent(v:Int):Void {}
+
+	public overload function onEvent() {
+		var b = Math.random() > 0.5 ? 1 : throw "no";
+	}
+
+	function test() {
+		Assert.pass();
+	}
+	#end
+}