Parcourir la source

[jvm] avoid duplicate implicit ctors in deeper hierarchies

closes #9548
Simon Krajewski il y a 5 ans
Parent
commit
0cc9fffb79
2 fichiers modifiés avec 30 ajouts et 2 suppressions
  1. 6 2
      src/generators/genshared.ml
  2. 24 0
      tests/unit/src/unit/issues/Issue9548.hx

+ 6 - 2
src/generators/genshared.ml

@@ -263,7 +263,7 @@ class ['a] preprocessor (basic : basic_types) (convert : Type.t -> 'a) =
 	in
 	let rec get_constructor c =
 		match c.cl_constructor, c.cl_super with
-		| Some cf, _ -> c,cf
+		| Some cf, _ -> cf
 		| None, None -> raise Not_found
 		| None, Some (csup,cparams) -> get_constructor csup
 	in
@@ -424,7 +424,11 @@ class ['a] preprocessor (basic : basic_types) (convert : Type.t -> 'a) =
 		match c.cl_constructor with
 		| None ->
 			begin try
-				let csup,cf = get_constructor c in
+				let cf = get_constructor c in
+				let csup = match c.cl_super with
+					| Some(c,_) -> c
+					| _ -> die "" __LOC__
+				in
 				List.iter (fun cf -> self#add_implicit_ctor c csup cf) (cf :: cf.cf_overloads)
 			with Not_found ->
 				()

+ 24 - 0
tests/unit/src/unit/issues/Issue9548.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+import haxe.Constraints.Function;
+
+private class ComponentBase {
+    public function new() {
+    }
+}
+
+private class ComponentImpl extends ComponentBase { }
+
+private class ComponentBounds extends ComponentImpl { }
+
+private class Component extends ComponentBounds {
+    public function new() {
+        super();
+    }
+}
+
+class Issue9548 extends unit.Test {
+	public function test() {
+		utest.Assert.pass();
+	}
+}