Kaynağa Gözat

fix properties typing for abstracts (fixes #7883)

Aleksandr Kuzmenko 6 yıl önce
ebeveyn
işleme
2005e6fc7e
2 değiştirilmiş dosya ile 21 ekleme ve 4 silme
  1. 4 4
      src/typing/fields.ml
  2. 17 0
      tests/unit/src/unit/issues/Issue7883.hx

+ 4 - 4
src/typing/fields.ml

@@ -524,10 +524,10 @@ let rec type_field cfg ctx e i p mode =
 			(match mode, f.cf_kind with
 			| (MGet | MCall), Var {v_read = AccCall } ->
 				(* getter call *)
-				let f = PMap.find ("get_" ^ f.cf_name) c.cl_statics in
-				let t = field_type f in
-				let r = match follow t with TFun(_,r) -> r | _ -> raise Not_found in
-				let ef = field_expr f t in
+				let getter = PMap.find ("get_" ^ f.cf_name) c.cl_statics in
+				let t = field_type getter in
+				let r = match follow t with TFun(_,_) -> f.cf_type | _ -> raise Not_found in
+				let ef = field_expr getter t in
 				AKExpr(make_call ctx ef [e] r p)
 			| MSet, Var {v_write = AccCall } ->
 				let f = PMap.find ("set_" ^ f.cf_name) c.cl_statics in

+ 17 - 0
tests/unit/src/unit/issues/Issue7883.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+class Issue7883 extends unit.Test {
+	function test() {
+		(0:A).x.f();
+		noAssert();
+	}
+}
+
+private abstract A(Int) from Int {
+	public var x(get,never):A;
+	function get_x() return 1;
+
+	public function f() {}
+
+	public function getX():A return 1;
+}