Bladeren bron

allow @:generic on abstract member functions (closes #1793)

Simon Krajewski 12 jaren geleden
bovenliggende
commit
de155bfebf
2 gewijzigde bestanden met toevoegingen van 3 en 1 verwijderingen
  1. 0 1
      typeload.ml
  2. 3 0
      typer.ml

+ 0 - 1
typeload.ml

@@ -1595,7 +1595,6 @@ let init_class ctx c p context_init herits fields =
 			if inline && c.cl_interface then error "You can't declare inline methods in interfaces" p;
 			if Meta.has Meta.Generic f.cff_meta then begin
 				if params = [] then error "Generic functions must have type parameters" p;
-				match c.cl_kind with KAbstractImpl _ -> error "Generic functions are not allowed on abstracts" p | _ -> ()
 			end;
 			let is_macro = is_macro || (is_class_macro && stat) in
 			let f, stat, fd = if not is_macro || stat then

+ 3 - 0
typer.ml

@@ -1374,6 +1374,9 @@ let type_generic_function ctx (e,cf) el ?(using_param=None) with_type p =
 	add_constraint_checks ctx c.cl_types [] cf monos p;
 	let args,ret = match t,using_param with
 		| TFun((_,_,ta) :: args,ret),Some e ->
+			let ta = if not (Meta.has Meta.Impl cf.cf_meta) then ta
+			else match follow ta with TAbstract(a,tl) -> Codegen.Abstract.get_underlying_type a tl | _ -> assert false
+			in
 			(* manually unify first argument *)
 			unify ctx e.etype ta p;
 			args,ret