Browse Source

[php7] fix "cannot implement previously implemented interface" (#6208)

Alexander Kuzmenko 8 years ago
parent
commit
fce175b423
2 changed files with 36 additions and 1 deletions
  1. 15 1
      src/generators/genphp7.ml
  2. 21 0
      tests/unit/src/unit/issues/Issue6208.hx

+ 15 - 1
src/generators/genphp7.ml

@@ -3246,7 +3246,21 @@ class class_builder ctx (cls:tclass) =
 					match iface with
 						| (i, params) -> writer#use_t (TInst (i, params))
 				in
-				let interfaces = List.map use_interface cls.cl_implements in
+				let unique = List.filter
+					(fun (iface, _) ->
+						not (List.exists
+							(fun (probably_descendant, _) ->
+								if probably_descendant == iface then
+									false
+								else
+									is_parent iface probably_descendant
+							)
+							cls.cl_implements
+						)
+					)
+					cls.cl_implements
+				in
+				let interfaces = List.map use_interface unique in
 				writer#write (String.concat ", " interfaces);
 			end;
 		(**

+ 21 - 0
tests/unit/src/unit/issues/Issue6208.hx

@@ -0,0 +1,21 @@
+package unit.issues;
+
+@:keep
+class Issue6208 extends unit.Test implements IBase implements IChild {
+
+    function test() {
+        t(Std.is(this, IChild));
+        t(Std.is(this, IBase));
+    }
+
+    public function base() {}
+    public function child() {}
+}
+
+@:keep interface IBase {
+    function base():Void;
+}
+
+@:keep interface IChild extends IBase {
+    function child():Void;
+}