Browse Source

[cs] Do not add explicit interfaces as their real fields' overload

Closes #4363
Cauê Waneck 10 years ago
parent
commit
e5e422d42b
2 changed files with 38 additions and 11 deletions
  1. 6 11
      gencommon.ml
  2. 32 0
      tests/unit/src/unit/issues/Issue4363.hx

+ 6 - 11
gencommon.ml

@@ -11126,17 +11126,12 @@ struct
 										etype = real_ftype;
 										epos = p;
 									};
-									(* delayed: add to class *)
-									let delay () =
-										try
-											let fm = PMap.find f.cf_name c.cl_fields in
-											fm.cf_overloads <- newf :: fm.cf_overloads
-										with | Not_found ->
-											c.cl_fields <- PMap.add f.cf_name newf c.cl_fields;
-											c.cl_ordered_fields <- newf :: c.cl_ordered_fields
-									in
-									(* gen.gafter_filters_ended <- delay :: gen.gafter_filters_ended *)
-									delay();
+									(try
+										let fm = PMap.find f.cf_name c.cl_fields in
+										fm.cf_overloads <- newf :: fm.cf_overloads
+									with | Not_found ->
+										c.cl_fields <- PMap.add f.cf_name newf c.cl_fields;
+										c.cl_ordered_fields <- newf :: c.cl_ordered_fields)
 								| _ -> assert false
 							end
 						with | Not_found -> ()

+ 32 - 0
tests/unit/src/unit/issues/Issue4363.hx

@@ -0,0 +1,32 @@
+package unit.issues;
+
+class Issue4363 extends Test
+{
+	public function test()
+	{
+		var i:I<C> = new C();
+		eq(null, i.f());
+		eq(i, i.f2());
+	}
+}
+
+private interface I<T> {
+	function f(?arg:Float):T;
+	function f2(?arg:Float):T;
+}
+
+private class C implements I<C> {
+	public function new()
+	{
+	}
+
+	public function f(?arg:Float):C
+	{
+		return null;
+	}
+
+	public function f2(?arg:Float):C
+	{
+		return this;
+	}
+}