Browse Source

allow any type on top of Dynamic in catch type params (closes #9641)

Aleksandr Kuzmenko 5 years ago
parent
commit
5319debd89
3 changed files with 18 additions and 1 deletions
  1. 4 0
      extra/CHANGES.txt
  2. 1 1
      src/typing/typer.ml
  3. 13 0
      tests/unit/src/unit/issues/Issue9641.hx

+ 4 - 0
extra/CHANGES.txt

@@ -1,5 +1,9 @@
 2020-XX-XX 4.1.4:
 
+	General improvements:
+
+	all : allowed `Any` as type parameter in `catch(e:SomeType<Any>)` (#9641)
+
 	Bugfixes:
 
 	php : fixed false detection of `catch` vars in anonymous functions as captured from outer scope

+ 1 - 1
src/typing/typer.ml

@@ -1877,7 +1877,7 @@ and type_try ctx e1 catches with_type p =
 	in
 	let check_catch_type_params params =
 		List.iter (fun pt ->
-			if pt != t_dynamic then error "Catch class parameter must be Dynamic" p;
+			if Abstract.follow_with_abstracts pt != t_dynamic then error "Catch class parameter must be Dynamic" p;
 		) params
 	in
 	let catches,el = List.fold_left (fun (acc1,acc2) ((v,pv),t,e_ast,pc) ->

+ 13 - 0
tests/unit/src/unit/issues/Issue9641.hx

@@ -0,0 +1,13 @@
+package unit.issues;
+
+class Issue9641 extends unit.Test {
+	function test() {
+		try {
+			throw new MyException<Int>('');
+		} catch(e:MyException<Any>) {
+			noAssert();
+		}
+	}
+}
+
+private class MyException<T> extends haxe.Exception {}