Parcourir la source

[swf] fix #9678 and add test (#9679)

* [swf] generate * type when Void ends up being used as value (see #9678)

* add test (closes #9678)

* disable #9678 test for C++ for now
Aleksandr Kuzmenko il y a 5 ans
Parent
commit
51188bc088
3 fichiers modifiés avec 26 ajouts et 2 suppressions
  1. 2 1
      extra/CHANGES.txt
  2. 1 1
      src/generators/genswf9.ml
  3. 23 0
      tests/unit/src/unit/issues/Issue9678.hx

+ 2 - 1
extra/CHANGES.txt

@@ -2,8 +2,9 @@
 
 	Bugfixes:
 
-	flash : fixed var shadowing issue for variables captured in a closure inside of a loop (#9624)
 	macro : fixed compiler crash if `@:genericBuild` meta is removed by a macro during building (#9391)
+	flash : fixed var shadowing issue for variables captured in a closure inside of a loop (#9624)
+	flash : fixed `VerifyError` exception when `Void` end up as an argument type after inlining (#9678)
 	nullsafety: fixed `@:nullSafety(Off)` in closures inside of constructors (#9643)
 	nullsafety: fixed "Type not found NullSafetyMode_Impl_" (#9483)
 

+ 1 - 1
src/generators/genswf9.ml

@@ -247,7 +247,7 @@ let rec type_id ctx t =
 
 let type_opt ctx t =
 	match follow_basic t with
-	| TDynamic _ | TMono _ -> None
+	| TDynamic _ | TMono _ | TAbstract ({a_path = [],"Void"},_) -> None
 	| _ -> Some (type_id ctx t)
 
 let type_void ctx t =

+ 23 - 0
tests/unit/src/unit/issues/Issue9678.hx

@@ -0,0 +1,23 @@
+package unit.issues;
+
+class Issue9678 extends unit.Test {
+	#if !cpp
+	function test() {
+		var called = 0;
+		function returnVoid() {
+			called++;
+		}
+		new C(42).next(returnVoid).handle(_ -> called++);
+		eq(2, called);
+	}
+
+	@:keep static function explicitVoidArg(arg:Void) {}
+	#end
+}
+
+private class C<T> {
+	final v:T;
+	public function new(v:T) this.v = v;
+	public function next<S>(f:()->S):C<S> return new C(f());
+	public function handle(cb:T->Void) {cb(v);}
+}