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

Fix for generic function through typedef (#6971)

Ben Morris 7 жил өмнө
parent
commit
4d477bbfc6

+ 6 - 2
src/typing/calls.ml

@@ -397,7 +397,11 @@ let unify_field_call ctx fa el args ret p inline =
 				a.a_path
 			| _ -> c.cl_path
 		in
-		let e = if stat then type_type ctx path p else e in
+		let e = match c.cl_kind with
+			| KAbstractImpl(a) ->
+				type_type ctx a.a_path p
+			| _ -> e
+		in
 		let fa = if stat then FStatic (c,cf2) else FInstance (c,tl,cf2) in
 		let e = mk (TField(e,fa)) cf2.cf_type p in
 		make_call ctx e el ret p
@@ -705,4 +709,4 @@ let type_bind ctx (e : texpr) (args,ret) params p =
 		tf_type = t_inner;
 		tf_expr = mk (TReturn (Some func)) t_inner p;
 	}) (TFun(outer_fun_args given_args, t_inner)) p in
-	make_call ctx func (List.map (fun (_,_,e) -> (match e with Some e -> e | None -> assert false)) given_args) t_inner p
+	make_call ctx func (List.map (fun (_,_,e) -> (match e with Some e -> e | None -> assert false)) given_args) t_inner p

+ 7 - 0
tests/unit/src/unit/issues/Issue5255.hx

@@ -0,0 +1,7 @@
+package unit.issues;
+
+class Issue5255 extends Test {
+	function test() {
+		eq(1, unit.issues.misc.Issue5255Class.test(1));
+	}
+}

+ 9 - 0
tests/unit/src/unit/issues/misc/Issue5255Class.hx

@@ -0,0 +1,9 @@
+package unit.issues.misc;
+
+typedef Issue5255Class<T> = Issue5255Class_<T>;
+
+class Issue5255Class_<T> {
+	@:generic public static function test<T>(arg:T){
+		return arg;
+	}
+}