2
0
Эх сурвалжийг харах

[generic] don't die on abstract functions

closes #10735
Simon Krajewski 2 жил өмнө
parent
commit
70479e8d19

+ 1 - 1
src/typing/generic.ml

@@ -291,7 +291,7 @@ let rec build_generic_class ctx c p tl =
 				begin try (match cf_old.cf_expr with
 					| None ->
 						begin match cf_old.cf_kind with
-							| Method _ when not (has_class_flag c CInterface) && not (has_class_flag c CExtern) ->
+							| Method _ when not (has_class_flag c CInterface) && not (has_class_flag c CExtern) && not (has_class_field_flag cf_old CfAbstract) ->
 								display_error ctx.com (Printf.sprintf "Field %s has no expression (possible typing order issue)" cf_new.cf_name) cf_new.cf_pos;
 								display_error ctx.com (Printf.sprintf "While building %s" (s_type_path cg.cl_path)) p;
 							| _ ->

+ 24 - 0
tests/unit/src/unit/issues/Issue10735.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+@:generic
+private abstract class A<T> {
+	var i:T;
+
+	public function new(i:T) {
+		this.i = i;
+	}
+
+	abstract function foo():T;
+}
+
+private class B extends A<Int> {
+	public function foo() {
+		return i;
+	}
+}
+
+class Issue10735 extends Test {
+	function test() {
+		eq(12, new B(12).foo());
+	}
+}