Selaa lähdekoodia

fix type parameter application when resolving unop overloads (closes #4357)

Simon Krajewski 10 vuotta sitten
vanhempi
commit
036dde6160
2 muutettua tiedostoa jossa 14 lisäystä ja 1 poistoa
  1. 13 0
      tests/unit/src/unit/issues/Issue4357.hx
  2. 1 1
      typer.ml

+ 13 - 0
tests/unit/src/unit/issues/Issue4357.hx

@@ -0,0 +1,13 @@
+package unit.issues;
+
+private abstract MyAbstract<T>(Array<T>) from Array<T> {
+	@:op(++A) public function pre()
+		return "pre";
+}
+
+class Issue4357 extends Test {
+	function test() {
+		var a:MyAbstract<Int> = [123];
+		eq("pre", ++a);
+	}
+}

+ 1 - 1
typer.ml

@@ -2363,7 +2363,7 @@ and type_unop ctx op flag e p =
 					| [] -> raise Not_found
 					| (op2,flag2,cf) :: opl when op == op2 && flag == flag2 ->
 						let m = mk_mono() in
-						let tcf = apply_params c.cl_params pl (monomorphs cf.cf_params cf.cf_type) in
+						let tcf = apply_params a.a_params pl (monomorphs cf.cf_params cf.cf_type) in
 						if Meta.has Meta.Impl cf.cf_meta then begin
 							if type_iseq (tfun [apply_params a.a_params pl a.a_this] m) tcf then cf,tcf,m else loop opl
 						end else