Nicolas Cannasse 18 years ago
parent
commit
d1b347697d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      typer.ml

+ 7 - 1
typer.ml

@@ -2407,7 +2407,13 @@ let init_class ctx c p herits fields =
 					let p = c.cl_pos in
 					let esuper = (ECall ((EConst (Ident "super"),p),List.map (fun (n,_,_) -> (EConst (Ident n),p)) f.f_args),p) in
 					let acc = (if csuper.cl_extern && acc = [] then [APublic] else acc) in
-					let fnew = { f with f_expr = esuper; f_args = List.map (fun (a,opt,_) -> a,opt,None) f.f_args } in
+					(* remove types that are superclass type-parameters *)
+					let replace_type = function
+						| Some (TPNormal { tpackage = []; tname = name; tparams = [] }) when List.exists (fun (param,_) -> name = param) csuper.cl_types ->
+							None
+						| t -> t
+					in
+					let fnew = { f with f_expr = esuper; f_args = List.map (fun (a,opt,t) -> a,opt,replace_type t) f.f_args } in
 					let _, _, cf, delayed = loop_cf (FFun ("new",None,acc,pl,fnew)) p in
 					c.cl_constructor <- Some cf;
 					Hashtbl.add ctx.constructs c.cl_path (acc,pl,f);