Browse Source

[java][cs] ignore @:generic base classes (fixes #9799)

Aleksandr Kuzmenko 5 years ago
parent
commit
56da6c9db4

+ 2 - 2
src/codegen/gencommon/gencommon.ml

@@ -691,7 +691,7 @@ let reorder_modules gen =
 
 let run_filters_from gen t filters =
 	match t with
-	| TClassDecl c ->
+	| TClassDecl c when not (FiltersCommon.is_removable_class c) ->
 		trace (snd c.cl_path);
 		gen.gcurrent_path <- c.cl_path;
 		gen.gcurrent_class <- Some(c);
@@ -719,7 +719,7 @@ let run_filters_from gen t filters =
 		| None -> ()
 		| Some e ->
 			c.cl_init <- Some (List.fold_left (fun e f -> f e) e filters));
-	| TEnumDecl _ | TTypeDecl _ | TAbstractDecl _ ->
+	| TClassDecl _ | TEnumDecl _ | TTypeDecl _ | TAbstractDecl _ ->
 		()
 
 let run_filters gen =

+ 23 - 0
tests/misc/cs/projects/Issue9799/Main.hx

@@ -0,0 +1,23 @@
+import haxe.Constraints.Constructible;
+
+@:generic
+class Test<T:Constructible<Void->Void>> {
+
+	var sleepAmount:Float = 0;
+
+	public function new() {
+		var fn = function() {
+			Sys.sleep(this.sleepAmount);
+		}
+	}
+}
+
+class BoringClass {
+	public function new() { }
+}
+
+class Main {
+	static function main() {
+		new Test<BoringClass>();
+	}
+}

+ 2 - 0
tests/misc/cs/projects/Issue9799/compile.hxml

@@ -0,0 +1,2 @@
+-main Main
+-cs bin

+ 23 - 0
tests/misc/java/projects/Issue9799/Main.hx

@@ -0,0 +1,23 @@
+import haxe.Constraints.Constructible;
+
+@:generic
+class Test<T:Constructible<Void->Void>> {
+
+	var sleepAmount:Float = 0;
+
+	public function new() {
+		var fn = function() {
+			Sys.sleep(this.sleepAmount);
+		}
+	}
+}
+
+class BoringClass {
+	public function new() { }
+}
+
+class Main {
+	static function main() {
+		new Test<BoringClass>();
+	}
+}

+ 2 - 0
tests/misc/java/projects/Issue9799/compile.hxml

@@ -0,0 +1,2 @@
+-main Main
+-java bin