Browse Source

fix issue #3214 again (closes #3214)

Simon Krajewski 11 years ago
parent
commit
e630d57f6e
2 changed files with 33 additions and 0 deletions
  1. 32 0
      tests/unit/issues/Issue3214.hx
  2. 1 0
      typer.ml

+ 32 - 0
tests/unit/issues/Issue3214.hx

@@ -0,0 +1,32 @@
+package unit.issues;
+
+private abstract Int64(Int64_t) {
+	inline private function new(i) {
+		this = i;
+	}
+
+	inline public static function make(a:Int, b:Int):Int64 {
+		return new Int64(cast a + b);
+	}
+
+	@:op(A*B) inline public function mul_i64(a:Int64):Int64 {
+		return new Int64(cast this.get() * a.get().get());
+	}
+
+	public function get() {
+		return this;
+	}
+}
+
+private abstract Int64_t(Dynamic) {
+	public function get() return this;
+}
+
+class Issue3214 extends unit.Test {
+	function test() {
+		var a = Int64.make(1,2);
+		var b = Int64.make(3,4);
+        var c = a * b;
+		eq(21, c.get().get());
+	}
+}

+ 1 - 0
typer.ml

@@ -2184,6 +2184,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
 						in
 						begin try
 							let monos,t1,t2 = map_arguments() in
+							let t1 = if Meta.has Meta.Impl cf.cf_meta then Abstract.follow_with_abstracts t1 else t1 in
 							let e1 = Codegen.AbstractCast.cast_or_unify_raise ctx t1 e1 p in
 							let e2 = Codegen.AbstractCast.cast_or_unify_raise ctx t2 e2 p in
 							check_constraints ctx "" cf.cf_params monos (apply_params a.a_params tl) false cf.cf_pos;