Browse Source

[analyzer] run on overloads too

closes #10405
Aleksandr Kuzmenko 3 years ago
parent
commit
e374c9c2d5
3 changed files with 22 additions and 0 deletions
  1. 1 0
      extra/CHANGES.txt
  2. 4 0
      src/optimization/analyzer.ml
  3. 17 0
      tests/unit/src/unit/issues/Issue10405.hx

+ 1 - 0
extra/CHANGES.txt

@@ -14,6 +14,7 @@
 	all : fixed errors on final vars modification with `+=`, `*=` etc operations (#10325)
 	all : fixed hanging of MainLoop.add on threaded targets (#10308, #10329)
 	all : fixed compiler crash when resolving overloads with not enough arguments (#10434)
+	analyzer : fixed analyzer on overloads (#10405)
 	display : improved code completion in anonymous objects declarations (#10414)
 	js : fixed IntMap for keys greater than 2^31 (#10316)
 	js : workaround to fix sourcemaps on Firefox in Windows (#10217)

+ 4 - 0
src/optimization/analyzer.ml

@@ -1085,6 +1085,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
+}