Browse Source

removed variance

Nicolas Cannasse 18 years ago
parent
commit
1f7cfc5e1f
12 changed files with 148 additions and 219 deletions
  1. 2 8
      ast.ml
  2. 1 0
      doc/CHANGES.txt
  3. 20 20
      genas3.ml
  4. 5 15
      genxml.ml
  5. 18 28
      parser.ml
  6. 3 3
      std/flash/Button.hx
  7. 3 3
      std/flash/MovieClip.hx
  8. 1 1
      std/flash/filters/ColorMatrixFilter.hx
  9. 2 2
      std/flash9/display/Graphics.hx
  10. 1 1
      std/flash9/filters/ColorMatrixFilter.hx
  11. 44 89
      type.ml
  12. 48 49
      typer.ml

+ 2 - 8
ast.ml

@@ -133,12 +133,6 @@ type while_flag =
 	| NormalWhile
 	| DoWhile
 
-type variance =
-	| VNo
-	| VCo
-	| VContra
-	| VBi
-
 type type_path_normal = {
 	tpackage : string list;
 	tname : string;
@@ -146,7 +140,7 @@ type type_path_normal = {
 }
 
 and type_param_or_const =
-	| TPType of variance * type_path
+	| TPType of type_path
 	| TPConst of constant
 
 and anonymous_field =
@@ -198,7 +192,7 @@ and expr_def =
 
 and expr = expr_def * pos
 
-type type_param = variance * string * type_path_normal list
+type type_param = string * type_path_normal list
 
 type documentation = string option
 

+ 1 - 0
doc/CHANGES.txt

@@ -1,5 +1,6 @@
 2007-??-??: 1.14
 	fixed no error when invalid "catch" expression
+	remove variance
 
 2007-05-18: 1.13
 	fixed bug with local variable masking package in catch type

+ 20 - 20
genas3.ml

@@ -40,14 +40,14 @@ let s_path ctx path p =
 	match path with
 	| ([],name) ->
 		(match name with
-		| "Int" -> "int"		
+		| "Int" -> "int"
 		| "Float" -> "Number"
 		| "Dynamic" -> "Object"
 		| "Bool" -> "Boolean"
 		| _ -> name)
 	| (["flash"],"FlashXml__") ->
 		"Xml"
-	| (pack,name) ->		
+	| (pack,name) ->
 		(try
 			let pack2 = Hashtbl.find ctx.imports name in
 			if pack2 <> pack then Typer.error ("The classes " ^ Ast.s_type_path (pack,name) ^ " and " ^ Ast.s_type_path (pack2,name) ^ " conflicts") p;
@@ -161,7 +161,7 @@ let parent e =
 	| TParenthesis _ -> e
 	| _ -> mk (TParenthesis e) e.etype e.epos
 
-let rec type_str ctx t p =	
+let rec type_str ctx t p =
 	match t with
 	| TEnum _ | TInst _ when List.memq t ctx.local_types ->
 		"*"
@@ -172,7 +172,7 @@ let rec type_str ctx t p =
 			| _ -> "Object"
 		) else
 			s_path ctx e.e_path p
-	| TInst (c,_) -> 
+	| TInst (c,_) ->
 		if (snd c.cl_path).[0] = '+' then "*" else s_path ctx c.cl_path p
 	| TFun _ ->
 		"Function"
@@ -185,7 +185,7 @@ let rec type_str ctx t p =
 		| [], "UInt" -> "uint"
 		| [] , "Null" ->
 			(match args with
-			| [_,t] ->
+			| [t] ->
 				(match follow t with
 				| TInst ({ cl_path = [],"Int" },_)
 				| TInst ({ cl_path = [],"Float" },_)
@@ -337,9 +337,9 @@ and gen_field_access ctx t s =
 		| [], "Date", "fromString"
 		| [], "Date", "toString"
 		| [], "String", "charCodeAt"
-		-> 
+		->
 			print ctx "[\"%s\"]" s
-		| _ -> 
+		| _ ->
 			print ctx ".%s" (s_ident s));
 	| _ ->
 		print ctx ".%s" (s_ident s)
@@ -418,7 +418,7 @@ and gen_expr ctx e =
 		b();
 	| TFunction f ->
 		let h = gen_function_header ctx None f [] e.epos in
-		gen_expr ctx (block f.tf_expr);		
+		gen_expr ctx (block f.tf_expr);
 		h();
 	| TCall (e,el) ->
 		gen_call ctx e el
@@ -484,7 +484,7 @@ and gen_expr ctx e =
 	| TFor (v,t,it,e) ->
 		let handle_break = handle_break ctx e in
 		let b = save_locals ctx in
-		let tmp = define_local ctx "$it" in		
+		let tmp = define_local ctx "$it" in
 		print ctx "{ var %s : * = " tmp;
 		gen_value ctx it;
 		newline ctx;
@@ -650,7 +650,7 @@ and gen_value ctx e =
 		let v = value true in
 		gen_expr ctx e;
 		v()
-	| TBlock el ->		
+	| TBlock el ->
 		let v = value true in
 		let rec loop = function
 			| [] ->
@@ -695,7 +695,7 @@ and gen_value ctx e =
 		)) e.etype e.epos);
 		v()
 
-let generate_boot_init ctx =	
+let generate_boot_init ctx =
 	print ctx "private static function init() : void {";
 	List.iter (gen_expr ctx) ctx.inits;
 	print ctx "}"
@@ -725,7 +725,7 @@ let generate_field ctx static f =
 		gen_expr ctx (block fd.tf_expr);
 		h()
 	| _ ->
-		if ctx.curclass.cl_path = (["flash"],"Boot") && f.cf_name = "init" then 
+		if ctx.curclass.cl_path = (["flash"],"Boot") && f.cf_name = "init" then
 			generate_boot_init ctx
 		else if not ctx.curclass.cl_interface then begin
 			print ctx "%s var %s : %s" rights (s_ident f.cf_name) (type_str ctx f.cf_type p);
@@ -747,7 +747,7 @@ let generate_class ctx c =
 	ctx.curclass <- c;
 	List.iter (define_getset ctx false) c.cl_ordered_fields;
 	List.iter (define_getset ctx true) c.cl_ordered_statics;
-	ctx.local_types <- List.map (fun (_,_,t) -> t) c.cl_types;
+	ctx.local_types <- List.map snd c.cl_types;
 	let pack = open_block ctx in
 	print ctx "\tpublic %s%s %s " (match c.cl_dynamic with None -> "" | Some _ -> "dynamic ") (if c.cl_interface then "interface" else "class") (snd c.cl_path);
 	(match c.cl_super with
@@ -792,7 +792,7 @@ let generate_class ctx c =
 	newline ctx
 
 let generate_main ctx c =
-	ctx.curclass <- c;	
+	ctx.curclass <- c;
 	let pack = open_block ctx in
 	print ctx "\tpublic class __main__ extends %s {" (s_path ctx (["flash";"display"],"MovieClip") c.cl_pos);
 	let cl = open_block ctx in
@@ -817,8 +817,8 @@ let generate_main ctx c =
 	print ctx "}";
 	newline ctx
 
-let generate_enum ctx e =	
-	ctx.local_types <- List.map (fun (_,_,t) -> t) e.e_types;
+let generate_enum ctx e =
+	ctx.local_types <- List.map snd e.e_types;
 	let pack = open_block ctx in
 	let ename = snd e.e_path in
 	print ctx "\tpublic class %s extends enum {" ename;
@@ -826,7 +826,7 @@ let generate_enum ctx e =
 	newline ctx;
 	print ctx "public static const __isenum : Boolean = true";
 	newline ctx;
-	print ctx "public function %s( t : String, p : Array = null ) : void { this.tag = t; this.params = p; }" ename;	
+	print ctx "public function %s( t : String, p : Array = null ) : void { this.tag = t; this.params = p; }" ename;
 	PMap.iter (fun _ c ->
 		newline ctx;
 		match c.ef_type with
@@ -852,7 +852,7 @@ let generate_enum ctx e =
 	newline ctx
 
 let generate_base_enum ctx =
-	let pack = open_block ctx in	
+	let pack = open_block ctx in
 	spr ctx "\tpublic class enum {";
 	let cl = open_block ctx in
 	newline ctx;
@@ -882,7 +882,7 @@ let generate dir types =
 			) in
 			(match c.cl_init with
 			| None -> ()
-			| Some e -> inits := e :: !inits);			
+			| Some e -> inits := e :: !inits);
 			if c.cl_extern then
 				()
 			else (match c.cl_path with
@@ -892,7 +892,7 @@ let generate dir types =
 				close ctx;
 			| ["flash"], "Boot" ->
 				boot := Some c;
-			| _ ->				
+			| _ ->
 				let ctx = init dir c.cl_path in
 				generate_class ctx c;
 				close ctx)

+ 5 - 15
genxml.ml

@@ -51,24 +51,14 @@ let gen_arg_name (name,opt,_) =
 let rec gen_type t =
 	match t with
 	| TMono m -> (match !m with None -> tag "unknown" | Some t -> gen_type t)
-	| TEnum (e,params) -> node "e" [gen_path e.e_path e.e_private] (List.map gen_ptype params)
-	| TInst (c,params) -> node "c" [gen_path c.cl_path c.cl_private] (List.map gen_ptype params)
-	| TType (t,params) -> node "t" [gen_path t.t_path t.t_private] (List.map gen_ptype params)
+	| TEnum (e,params) -> node "e" [gen_path e.e_path e.e_private] (List.map gen_type params)
+	| TInst (c,params) -> node "c" [gen_path c.cl_path c.cl_private] (List.map gen_type params)
+	| TType (t,params) -> node "t" [gen_path t.t_path t.t_private] (List.map gen_type params)
 	| TFun (args,r) -> node "f" ["a",String.concat ":" (List.map gen_arg_name args)] (List.map gen_type (List.map (fun (_,_,t) -> t) args @ [r]))
 	| TAnon a -> node "a" [] (pmap (fun f -> node f.cf_name [] [gen_type f.cf_type]) a.a_fields)
 	| TDynamic t2 -> node "d" [] (if t == t2 then [] else [gen_type t2])
 	| TLazy f -> gen_type (!f())
 
-and gen_ptype (v,t) =
-	match gen_type t with
-	| Node (name,att,c) as n ->
-		(match v with
-		| VNo -> n
-		| VBi -> Node (name,("v","*") :: att,c)
-		| VCo -> Node (name,("v","+") :: att,c)
-		| VContra -> Node (name,("v","-") :: att,c))
-	| _ -> assert false
-
 let gen_constr e =
 	let doc = gen_doc_opt e.ef_doc in
 	let args, t = (match follow e.ef_type with
@@ -97,10 +87,10 @@ let gen_field att f =
 let gen_type_params priv path params pos m =
 	let mpriv = (if priv then [("private","1")] else []) in
 	let mpath = (if m.mpath <> path then [("module",snd (gen_path m.mpath false))] else []) in
-	gen_path path priv :: ("params", String.concat ":" (List.map (fun (_,n,_) -> n) params)) :: ("file",if pos == null_pos then "" else pos.pfile) :: (mpriv @ mpath)
+	gen_path path priv :: ("params", String.concat ":" (List.map fst params)) :: ("file",if pos == null_pos then "" else pos.pfile) :: (mpriv @ mpath)
 
 let gen_class_path name (c,pl) =
-	node name [("path",s_type_path c.cl_path)] (List.map gen_ptype pl)
+	node name [("path",s_type_path c.cl_path)] (List.map gen_type pl)
 
 let rec exists f c =
 	try

+ 18 - 28
parser.ml

@@ -56,7 +56,7 @@ let do_resume() = !resume_display <> null_pos
 
 let display e = raise (Display e)
 
-let is_resuming p = 
+let is_resuming p =
 	let p2 = !resume_display in
 	p.pmax = p2.pmin && (!Plugin.get_full_path) p.pfile = p2.pfile
 
@@ -214,13 +214,13 @@ and parse_class_field_resume s =
 			| [Kwd Private; Kwd Interface]
 			| [Kwd Private; Kwd Enum]
 			| [Kwd Private; Kwd Typedef] ->
-				raise Not_found	
+				raise Not_found
 			| [Kwd Function; Const _]
 			| [Kwd Function; Kwd New] ->
 				raise Exit
 			| _ -> ());
 			Stream.junk s;
-			loop();	
+			loop();
 		in
 		try
 			loop();
@@ -228,7 +228,7 @@ and parse_class_field_resume s =
 			| Not_found ->
 				[]
 			| Exit ->
-				try 
+				try
 					let c = parse_class_field s in
 					c :: parse_class_field_resume s
 				with
@@ -285,7 +285,7 @@ and parse_type_path1 pack = parser
 			parse_type_path1 (name :: pack) s
 	| [< '(Const (Type name),_); s >] ->
 		let params = (match s with parser
-			| [< '(Binop OpLt,_); l = psep Comma parse_type_path_variance; '(Binop OpGt,_) >] -> l
+			| [< '(Binop OpLt,_); l = psep Comma parse_type_path_or_const; '(Binop OpGt,_) >] -> l
 			| [< >] -> []
 		) in
 		{
@@ -294,17 +294,11 @@ and parse_type_path1 pack = parser
 			tparams = params
 		}
 
-and parse_type_path_variance = parser
-	| [< '(Binop OpAdd,_); t = parse_type_path_or_const VCo >] -> t
-	| [< '(Binop OpSub,_); t = parse_type_path_or_const VContra >] -> t
-	| [< '(Binop OpMult,_); t = parse_type_path_or_const VBi >] -> t
-	| [< t = parse_type_path_or_const VNo >] -> t
-
-and parse_type_path_or_const v = parser
+and parse_type_path_or_const = parser
 	| [< '(Const (String s),_); >] -> TPConst (String s)
 	| [< '(Const (Int i),_); >] -> TPConst (Int i)
 	| [< '(Const (Float f),_); >] -> TPConst (Float f)
-	| [< t = parse_type_path >] -> TPType (v, t)
+	| [< t = parse_type_path >] -> TPType t
 
 and parse_type_path_next t = parser
 	| [< '(Arrow,_); t2 = parse_type_path >] ->
@@ -408,18 +402,14 @@ and parse_constraint_params = parser
 	| [< >] -> []
 
 and parse_constraint_param = parser
-	| [< '(Binop OpAdd,_); '(Const (Type name),_); s >] -> parse_constraint_param_next VCo name s
-	| [< '(Binop OpSub,_); '(Const (Type name),_); s >] -> parse_constraint_param_next VContra name s
-	| [< '(Binop OpMult,_); '(Const (Type name),_); s >] -> parse_constraint_param_next VBi name s
-	| [< '(Const (Type name),_); s >] -> parse_constraint_param_next VNo name s
-
-and parse_constraint_param_next v name = parser
-	| [< '(DblDot,_); s >] ->
-		(match s with parser
-		| [< '(POpen,_); l = psep Comma parse_type_path_normal; '(PClose,_) >] -> (v,name,l)
-		| [< t = parse_type_path_normal >] -> (v,name,[t])
-		| [< >] -> serror())
-	| [< >] -> (v,name,[])
+	| [< '(Const (Type name),_); s >] ->
+		match s with parser
+		| [< '(DblDot,_); s >] ->
+			(match s with parser
+			| [< '(POpen,_); l = psep Comma parse_type_path_normal; '(PClose,_) >] -> (name,l)
+			| [< t = parse_type_path_normal >] -> (name,[t])
+			| [< >] -> serror())
+		| [< >] -> (name,[])
 
 and parse_class_herit = parser
 	| [< '(Kwd Extends,_); t = parse_type_path_normal >] -> HExtends t
@@ -443,7 +433,7 @@ and block2 name ident p = parser
 				EBlock (block [e] s)
 
 and block acc s =
-	try		
+	try
 		let e = parse_block_elt s in
 		block (e :: acc) s
 	with
@@ -510,8 +500,8 @@ and expr = parser
 		| [< >] -> serror())
 	| [< '(POpen,p1); e = expr; '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
 	| [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s
-	| [< '(Kwd Function,p1); '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->		
-		let make e = 
+	| [< '(Kwd Function,p1); '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->
+		let make e =
 			let f = {
 				f_type = t;
 				f_args = al;

+ 3 - 3
std/flash/Button.hx

@@ -31,7 +31,7 @@ implements Dynamic
 	var _y : Float;
 	var _ymouse : Float;
 	var _yscale : Float;
-	
+
 	function onDragOut() : Void;
 	function onDragOver() : Void;
 	function onKeyDown() : Void;
@@ -43,11 +43,11 @@ implements Dynamic
 	function onRollOut() : Void;
 	function onRollOver() : Void;
 	function onSetFocus(oldFocus : Dynamic) : Void;
-	
+
 	function getDepth() : Int;
 
 #if flash8
-	var filters : Array<+flash.filters.BitmapFilter>;
+	var filters : Array<Dynamic>;
 	var blendMode : Dynamic;
 	var cacheAsBitmap : Bool;
 	var scale9Grid : flash.geom.Rectangle<Float>;

+ 3 - 3
std/flash/MovieClip.hx

@@ -93,9 +93,9 @@ implements Dynamic
 #end
 
 #if flash8
-	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<+Float>, ratios : Array<+Float>, matrix : Dynamic, ?spreadMethod : String, ?interpolationMethod : String, ?focalPointRatio : Float ) : Void;
+	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, matrix : Dynamic, ?spreadMethod : String, ?interpolationMethod : String, ?focalPointRatio : Float ) : Void;
 #else true
-	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<+Float>, ratios : Array<+Float>, matrix : Dynamic) : Void;
+	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, matrix : Dynamic) : Void;
 #end
 	// matrix : flash.geom.Matrix | Anonymous object a...i | Anonymous object (matrixType x,y,w,h,r)
 
@@ -152,7 +152,7 @@ implements Dynamic
 
 	function attachBitmap( bmp : flash.display.BitmapData, depth : Int, ?pixelSnapping : String, ?smoothing : Bool ) : Void;
 	function beginBitmapFill( bmp : flash.display.BitmapData , ?matrix:flash.geom.Matrix, ?repeat:Bool, ?smoothing:Bool ) : Void;
-  	function lineGradientStyle( fillType:String, colors:Array<Int>, alphas:Array<+Float>, ratios:Array<+Float>, matrix:Dynamic, ?spreadMethod : String, ?interpolationMethod:String, ?focalPointRatio:Float ) : Void;
+  	function lineGradientStyle( fillType:String, colors:Array<Int>, alphas:Array<Dynamic>, ratios:Array<Dynamic>, matrix:Dynamic, ?spreadMethod : String, ?interpolationMethod:String, ?focalPointRatio:Float ) : Void;
 
 #end
 

+ 1 - 1
std/flash/filters/ColorMatrixFilter.hx

@@ -4,7 +4,7 @@ extern class ColorMatrixFilter extends BitmapFilter {
 
 	var matrix : Array<Float>; // 20 Numbers
 
-	function new( ?matrix : Array<+Float> ) : Void;
+	function new( ?matrix : Array<Dynamic> ) : Void;
 	function clone() : ColorMatrixFilter;
 
 }

+ 2 - 2
std/flash9/display/Graphics.hx

@@ -4,7 +4,7 @@ extern class Graphics {
 	function new() : Void;
 	function beginBitmapFill(bitmap : BitmapData, ?matrix : flash.geom.Matrix, ?repeat : Bool, ?smooth : Bool) : Void;
 	function beginFill(color : UInt, ?alpha : Float) : Void;
-	function beginGradientFill(type : GradientType, colors : Array<UInt>, alphas : Array<+Float>, ratios : Array<+Float>, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, ?focalPointRatio : Float) : Void;
+	function beginGradientFill(type : GradientType, colors : Array<UInt>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, ?focalPointRatio : Float) : Void;
 	function clear() : Void;
 	function curveTo(controlX : Float, controlY : Float, anchorX : Float, anchorY : Float) : Void;
 	function drawCircle(x : Float, y : Float, radius : Float) : Void;
@@ -13,7 +13,7 @@ extern class Graphics {
 	function drawRoundRect(x : Float, y : Float, width : Float, height : Float, ellipseWidth : Float, ?ellipseHeight : Float) : Void;
 	function drawRoundRectComplex(x : Float, y : Float, width : Float, height : Float, topLeftRadius : Float, topRightRadius : Float, bottomLeftRadius : Float, bottomRightRadius : Float) : Void;
 	function endFill() : Void;
-	function lineGradientStyle(type : GradientType, colors : Array<UInt>, alphas : Array<+Float>, ratios : Array<+Float>, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, ?focalPointRatio : Float) : Void;
+	function lineGradientStyle(type : GradientType, colors : Array<UInt>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, ?focalPointRatio : Float) : Void;
 	function lineStyle(?thickness : Float, ?color : UInt, ?alpha : Float, ?pixelHinting : Bool, ?scaleMode : LineScaleMode, ?caps : CapsStyle, ?joints : JointStyle, ?miterLimit : Float) : Void;
 	function lineTo(x : Float, y : Float) : Void;
 	function moveTo(x : Float, y : Float) : Void;

+ 1 - 1
std/flash9/filters/ColorMatrixFilter.hx

@@ -2,5 +2,5 @@ package flash.filters;
 
 extern class ColorMatrixFilter extends flash.filters.BitmapFilter {
 	function new(?matrix : Array<Dynamic>) : Void;
-	var matrix : Array<Dynamic>;
+	var matrix : Array<Float>;
 }

+ 44 - 89
type.ml

@@ -31,8 +31,6 @@ type anon_status =
 	| Opened
 	| Statics
 
-type variance = Ast.variance
-
 type t =
 	| TMono of t option ref
 	| TEnum of tenum * tparams
@@ -43,7 +41,7 @@ type t =
 	| TDynamic of t
 	| TLazy of (unit -> t) ref
 
-and tparams = (variance * t) list
+and tparams = t list
 
 and tconstant =
 	| TInt of int32
@@ -117,7 +115,7 @@ and tclass = {
 	cl_private : bool;
 	mutable cl_extern : bool;
 	mutable cl_interface : bool;
-	mutable cl_types : (variance * string * t) list;
+	mutable cl_types : (string * t) list;
 	mutable cl_super : (tclass * tparams) option;
 	mutable cl_implements : (tclass * tparams) list;
 	mutable cl_fields : (string , tclass_field) PMap.t;
@@ -143,7 +141,7 @@ and tenum = {
 	e_doc : Ast.documentation;
 	e_private : bool;
 	e_extern : bool;
-	mutable e_types : (variance * string * t) list;
+	mutable e_types : (string * t) list;
 	mutable e_constrs : (string , tenum_field) PMap.t;
 }
 
@@ -153,7 +151,7 @@ and tdef = {
 	t_doc : Ast.documentation;
 	t_private : bool;
 	t_static : tclass option;
-	mutable t_types : (variance * string * t) list;
+	mutable t_types : (string * t) list;
 	mutable t_type : t;
 }
 
@@ -249,7 +247,7 @@ let rec s_type ctx t =
 		let fl = PMap.fold (fun f acc -> (" " ^ f.cf_name ^ " : " ^ s_type ctx f.cf_type) :: acc) a.a_fields [] in
 		"{" ^ (if not (is_closed a) then "+" else "") ^  String.concat "," fl ^ " }"
 	| TDynamic t2 ->
-		"Dynamic" ^ s_type_params ctx (if t == t2 then [] else [VNo,t2])
+		"Dynamic" ^ s_type_params ctx (if t == t2 then [] else [t2])
 	| TLazy f ->
 		s_type ctx (!f())
 
@@ -261,13 +259,7 @@ and s_fun ctx t void =
 
 and s_type_params ctx = function
 	| [] -> ""
-	| l -> "<" ^ String.concat ", " (List.map (fun (v,t) -> s_var v ^ s_type ctx t) l) ^ ">"
-
-and s_var = function
-	| VNo -> ""
-	| VCo -> "+"
-	| VContra -> "-"
-	| VBi -> "*"
+	| l -> "<" ^ String.concat ", " (List.map (s_type ctx) l) ^ ">"
 
 let rec is_parent csup c =
 	if c == csup then
@@ -282,8 +274,8 @@ let rec link e a b =
 			true
 		else match t with
 		| TMono t -> (match !t with None -> false | Some t -> loop t)
-		| TEnum (e,tl) -> e.e_path = ([],"Protected") || List.exists (fun (_,t) -> loop t) tl
-		| TInst (_,tl) | TType (_,tl) -> List.exists (fun (_,t) -> loop t) tl
+		| TEnum (e,tl) -> e.e_path = ([],"Protected") || List.exists loop tl
+		| TInst (_,tl) | TType (_,tl) -> List.exists loop tl
 		| TFun (tl,t) -> List.exists (fun (_,_,t) -> loop t) tl || loop t
 		| TDynamic t2 ->
 			if t == t2 then
@@ -323,82 +315,64 @@ let apply_params cparams params t =
 	let rec loop l1 l2 =
 		match l1, l2 with
 		| [] , [] -> []
-		| (a,b,TLazy f) :: l1, _ -> loop ((a,b,(!f)()) :: l1) l2
-		| (_,_,t1) :: l1 , (v,t2) :: l2 -> (t1,(v,t2)) :: loop l1 l2
+		| (x,TLazy f) :: l1, _ -> loop ((x,(!f)()) :: l1) l2
+		| (_,t1) :: l1 , t2 :: l2 -> (t1,t2) :: loop l1 l2
 		| _ -> assert false
 	in
-	let protect() =
-		TEnum ({
-			e_path = [] , "Protected";
-			e_pos = null_pos;
-			e_doc = None;
-			e_private = false;
-			e_extern = true;
-			e_types = [];
-			e_constrs = PMap.empty;
-		},[])
-	in
 	let subst = loop cparams params in
-	let rec loop v t =
+	let rec loop t =
 		try
-			let v2, t = List.assq t subst in
-			(match v2 with
-			| VCo when v <> VContra -> VNo, protect()
-			| VContra when v <> VCo -> VNo, protect()
-			| VBi -> VNo, protect()
-			| _ -> v2, t)
+			List.assq t subst
 		with Not_found ->
 		match t with
 		| TMono r ->
 			(match !r with
-			| None -> v, t
-			| Some t -> loop v t)
+			| None -> t
+			| Some t -> loop t)
 		| TEnum (e,tl) ->
-			v, (match tl with
+			(match tl with
 			| [] -> t
-			| _ -> TEnum (e,List.map (vloop v) tl))
+			| _ -> TEnum (e,List.map loop tl))
 		| TType (t2,tl) ->
-			v, (match tl with
+			(match tl with
 			| [] -> t
-			| _ -> TType (t2,List.map (vloop v) tl))
+			| _ -> TType (t2,List.map loop tl))
 		| TInst (c,tl) ->
-			v, (match tl with
+			(match tl with
 			| [] ->
 				t
-			| [mv,TMono r] ->
+			| [TMono r] ->
 				(match !r with
 				| Some tt when t == tt ->
 					(* for dynamic *)
 					let pt = mk_mono() in
-					let t = TInst (c,[mv,pt]) in
+					let t = TInst (c,[pt]) in
 					(match pt with TMono r -> r := Some t | _ -> assert false);
 					t
-				| _ -> TInst (c,List.map (vloop v) tl))
+				| _ -> TInst (c,List.map loop tl))
 			| _ ->
-				TInst (c,List.map (vloop v) tl))
+				TInst (c,List.map loop tl))
 		| TFun (tl,r) ->
-			v, TFun (List.map (fun (s,o,t) -> s, o, snd (loop VCo t)) tl,snd (loop VContra r))
+			TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r)
 		| TAnon a ->
-			v, TAnon {
-				a_fields = PMap.map (fun f -> { f with cf_type = snd (loop VCo f.cf_type) }) a.a_fields;
+			TAnon {
+				a_fields = PMap.map (fun f -> { f with cf_type = loop f.cf_type }) a.a_fields;
 				a_status = a.a_status;
 			}
 		| TLazy f ->
 			let ft = !f() in
-			let v , ft2 = loop v ft in
+			let ft2 = loop ft in
 			if ft == ft2 then
-				v, t
+				t
 			else
-				v, ft2
+				ft2
 		| TDynamic t2 ->
 			if t == t2 then
-				v, t
+				t
 			else
-				v, TDynamic (snd (loop VNo t2))
-	and vloop v (v2,t) =
-		loop v2 t
+				TDynamic (loop t2)
 	in
-	snd (loop VNo t)
+	loop t
 
 let rec follow t =
 	match t with
@@ -413,7 +387,7 @@ let rec follow t =
 	| _ -> t
 
 let monomorphs eparams t =
-	apply_params eparams (List.map (fun (v,_,_) -> v , mk_mono()) eparams) t
+	apply_params eparams (List.map (fun _ -> mk_mono()) eparams) t
 
 let rec fast_eq a b =
 	if a == b then
@@ -422,17 +396,14 @@ let rec fast_eq a b =
 	| TFun (l1,r1) , TFun (l2,r2) ->
 		List.for_all2 (fun (_,_,t1) (_,_,t2) -> fast_eq t1 t2) l1 l2 && fast_eq r1 r2
 	| TType (t1,l1), TType (t2,l2) ->
-		t1 == t2 && List.for_all2 fast_peq l1 l2
+		t1 == t2 && List.for_all2 fast_eq l1 l2
 	| TEnum (e1,l1), TEnum (e2,l2) ->
-		e1 == e2 && List.for_all2 fast_peq l1 l2
+		e1 == e2 && List.for_all2 fast_eq l1 l2
 	| TInst (c1,l1), TInst (c2,l2) ->
-		c1 == c2 && List.for_all2 fast_peq l1 l2
+		c1 == c2 && List.for_all2 fast_eq l1 l2
 	| _ , _ ->
 		false
 
-and fast_peq (_,a) (_,b) =
-	fast_eq a b
-
 (* perform unification with subtyping.
    the first type is always the most down in the class hierarchy
    it's also the one that is pointed by the position.
@@ -482,7 +453,7 @@ let rec type_eq param a b =
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| Some t -> type_eq param a t)
 	| TType (t1,tl1), TType (t2,tl2) when t1 == t2 && List.length tl1 = List.length tl2 ->
-		List.iter2 (fun (_,t1) (_,t2) -> type_eq param t1 t2) tl1 tl2
+		List.iter2 (type_eq param) tl1 tl2
 	| TType (t,tl) , _ -> type_eq param (apply_params t.t_types tl t.t_type) b
 	| _ , TType (t,tl) ->
 		if List.exists (fun (a2,b2) -> fast_eq a a2 && fast_eq b b2) (!eq_stack) then
@@ -499,10 +470,10 @@ let rec type_eq param a b =
 		end
 	| TEnum (e1,tl1) , TEnum (e2,tl2) ->
 		if e1 != e2 then error [cannot_unify a b];
-		List.iter2 (type_peq param) tl1 tl2
+		List.iter2 (type_eq param) tl1 tl2
 	| TInst (c1,tl1) , TInst (c2,tl2) ->
 		if c1 != c2 then error [cannot_unify a b];
-		List.iter2 (type_peq param) tl1 tl2
+		List.iter2 (type_eq param) tl1 tl2
 	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
 		(try
 			type_eq param r1 r2;
@@ -548,9 +519,6 @@ let rec type_eq param a b =
 		else
 			error [cannot_unify a b]
 
-and type_peq params (_,a) (_,b) =
-	type_eq params a b
-
 let type_iseq a b =
 	try
 		type_eq EqStrict a b;
@@ -563,7 +531,7 @@ let unify_stack = ref []
 let field_type f =
 	match f.cf_params with
 	| [] -> f.cf_type
-	| l -> monomorphs (List.map (fun (n,t) -> VNo, n, t) l) f.cf_type
+	| l -> monomorphs l f.cf_type
 
 let rec class_field c i =
 	try
@@ -603,7 +571,7 @@ let rec unify a b =
 		(match !t with
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| Some t -> unify a t)
-	| TType ({ t_static = Some cl },params), TInst ({ cl_path = [],"Class" },[_,pt]) ->
+	| TType ({ t_static = Some cl },params), TInst ({ cl_path = [],"Class" },[pt]) ->
 		unify (TInst (cl,params)) pt
 	| TType (t,tl) , _ ->
 		(try
@@ -632,9 +600,9 @@ let rec unify a b =
 			end else (match c.cl_super with
 				| None -> false
 				| Some (cs,tls) ->
-					loop cs (List.map (fun (v,t) -> v , apply_params c.cl_types tl t) tls)
+					loop cs (List.map (apply_params c.cl_types tl) tls)
 			) || List.exists (fun (cs,tls) ->
-				loop cs (List.map (fun (v,t) -> v , apply_params c.cl_types tl t) tls)
+				loop cs (List.map (apply_params c.cl_types tl) tls)
 			) c.cl_implements
 		in
 		if not (loop c1 tl1) then error [cannot_unify a b]
@@ -713,20 +681,7 @@ let rec unify a b =
 
 and unify_types a b tl1 tl2 =
 	try
-		List.iter2 (fun (va,ta) (vb,tb) ->
-			(match va, vb with
-			| VNo , _
-			| VCo , VCo
-			| VContra, VContra
-			| _ , VBi -> ()
-			| _  -> error []
-			);
-			match vb with
-			| VNo -> type_eq EqRightDynamic ta tb
-			| VCo -> unify ta tb
-			| VContra -> unify tb ta
-			| VBi -> ()
-		) tl1 tl2
+		List.iter2 (type_eq EqRightDynamic) tl1 tl2
 	with
 		Unify_error l -> error ((cannot_unify a b) :: l)
 

+ 48 - 49
typer.ml

@@ -300,15 +300,15 @@ let rec load_normal_type ctx t p allow_no_params =
 			| TTypeDecl t -> t.t_types , t.t_path , (fun tl -> TType(t,tl))
 		in
 		if allow_no_params && t.tparams = [] then
-			f (List.map (fun (v,name,t) ->
+			f (List.map (fun (name,t) ->
 				match follow t with
-				| TEnum _ -> v, mk_mono()
+				| TEnum _ -> mk_mono()
 				| _ -> error ("Type parameter " ^ name ^ " need constraint") p
 			) types)
 		else if path = ([],"Dynamic") then
 			match t.tparams with
 			| [] -> t_dynamic
-			| [TPType (_,t)] -> TDynamic (load_type ctx p t)
+			| [TPType t] -> TDynamic (load_type ctx p t)
 			| _ -> error "Too many parameters for Dynamic" p
 		else begin
 			if List.length types <> List.length t.tparams then error ("Invalid number of type parameters for " ^ s_type_path path) p;
@@ -321,11 +321,11 @@ let rec load_normal_type ctx t p allow_no_params =
 						| Float f -> "F" ^ f
 						| _ -> assert false
 					) in
-					VNo, TEnum ({ e_path = ([],name); e_pos = p; e_doc = None; e_private = false; e_extern = true; e_types = []; e_constrs = PMap.empty },[]), true
-				| TPType (v1,t) -> v1, load_type ctx p t, false
+					TEnum ({ e_path = ([],name); e_pos = p; e_doc = None; e_private = false; e_extern = true; e_types = []; e_constrs = PMap.empty },[]), true
+				| TPType t -> load_type ctx p t, false
 			) t.tparams in
-			let bparams = List.map (fun (v1,t,_) -> v1,t) tparams in
-			let params = List.map2 (fun (v1,t,isconst) (v2,name,t2) ->
+			let bparams = List.map fst tparams in
+			let params = List.map2 (fun (t,isconst) (name,t2) ->
 				if isconst <> (name = "Const") then error (if isconst then "Constant value unexpected here" else "Constant value excepted as type parameter") p;
 				(match follow t2 with
 				| TInst (c,[]) ->
@@ -334,7 +334,7 @@ let rec load_normal_type ctx t p allow_no_params =
 					) c.cl_implements
 				| TEnum (c,[]) -> ()
 				| _ -> assert false);
-				(match v1 with VNo -> v2 | _ -> v1) , t
+				t
 			) tparams types in
 			f params
 		end
@@ -430,12 +430,12 @@ let rec reverse_type t =
 			(f.cf_name , Some f.cf_public, AFVar (reverse_type f.cf_type), null_pos) :: acc
 		) a.a_fields [])
 	| TDynamic t2 ->
-		TPNormal { tpackage = []; tname = "Dynamic"; tparams = if t == t2 then [] else [TPType (VNo,reverse_type t2)] }
+		TPNormal { tpackage = []; tname = "Dynamic"; tparams = if t == t2 then [] else [TPType (reverse_type t2)] }
 	| _ ->
 		raise Exit
 
-and reverse_param (v,t) =
-	TPType (v , reverse_type t)
+and reverse_param t =
+	TPType (reverse_type t)
 
 let extend_remoting ctx c t p async prot =
 	if c.cl_super <> None then error "Cannot extend several classes" p;
@@ -545,18 +545,18 @@ let extend_proxy ctx c t p =
 		| _ ->
 			error "Proxy type parameter should be a class" p
 	) in
-	let tproxy = { tpackage = ["haxe"]; tname = "Proxy"; tparams = [TPType (VNo,TPNormal t)] } in
+	let tproxy = { tpackage = ["haxe"]; tname = "Proxy"; tparams = [TPType (TPNormal t)] } in
 	let pname = "P" ^ t.tname in
 	let class_decl = (EClass {
 		d_name = pname;
 		d_doc = None;
-		d_params = List.map (fun (v,s,_) -> v,s,[]) c.cl_types;
+		d_params = List.map (fun (s,_) -> s,[]) c.cl_types;
 		d_flags = [HExtends tproxy; HImplements t];
 		d_data = class_fields;
 	},p) in
 	let m = (!type_module_ref) ctx ("Proxy" :: t.tpackage, pname) [class_decl] p in
 	c.cl_super <- Some (match m.mtypes with
-		| [TClassDecl c2] -> (c2,List.map (fun (v,_,t) -> v,t) c.cl_types)
+		| [TClassDecl c2] -> (c2,List.map snd c.cl_types)
 		| _ -> assert false
 	)
 
@@ -564,13 +564,13 @@ let set_heritance ctx c herits p =
 	let rec loop = function
 		| HPrivate | HExtern | HInterface ->
 			()
-		| HExtends { tpackage = ["haxe";"remoting"]; tname = "Proxy"; tparams = [TPType(_,TPNormal t)] } ->
+		| HExtends { tpackage = ["haxe";"remoting"]; tname = "Proxy"; tparams = [TPType(TPNormal t)] } ->
 			extend_remoting ctx c t p false true
-		| HExtends { tpackage = ["haxe";"remoting"]; tname = "AsyncProxy"; tparams = [TPType(_,TPNormal t)] } ->
+		| HExtends { tpackage = ["haxe";"remoting"]; tname = "AsyncProxy"; tparams = [TPType(TPNormal t)] } ->
 			extend_remoting ctx c t p true true
-		| HExtends { tpackage = ["mt"]; tname = "AsyncProxy"; tparams = [TPType(_,TPNormal t)] } ->
+		| HExtends { tpackage = ["mt"]; tname = "AsyncProxy"; tparams = [TPType(TPNormal t)] } ->
 			extend_remoting ctx c t p true false
-		| HExtends { tpackage = ["haxe"]; tname = "Proxy"; tparams = [TPType(_,TPNormal t)] } when match c.cl_path with "Proxy" :: _ , _ -> false | _ -> true ->
+		| HExtends { tpackage = ["haxe"]; tname = "Proxy"; tparams = [TPType(TPNormal t)] } when match c.cl_path with "Proxy" :: _ , _ -> false | _ -> true ->
 			extend_proxy ctx c t p
 		| HExtends t ->
 			if c.cl_super <> None then error "Cannot extend several classes" p;
@@ -595,7 +595,7 @@ let set_heritance ctx c herits p =
 	in
 	List.iter loop herits
 
-let type_type_params ctx path p (v,n,flags) =
+let type_type_params ctx path p (n,flags) =
 	let t = (match flags with
 	| [] ->
 		(* build a phantom enum *)
@@ -621,7 +621,7 @@ let type_type_params ctx path p (v,n,flags) =
 		ctx.delays := [(fun () -> ignore(!r()))] :: !(ctx.delays);
 		TLazy r
 	) in
-	v, n , t
+	n , t
 
 let hide_types ctx =
 	let old_locals = ctx.local_types in
@@ -659,25 +659,25 @@ let is_float t =
 	| _ ->
 		false
 
-let t_array ctx v =
+let t_array ctx =
 	let show = hide_types ctx in
 	match load_type_def ctx null_pos ([],"Array") with
 	| TClassDecl c ->
 		show();
 		if List.length c.cl_types <> 1 then assert false;
 		let pt = mk_mono() in
-		TInst (c,[v,pt]) , pt
+		TInst (c,[pt]) , pt
 	| _ ->
 		assert false
 
-let t_array_access ctx v =
+let t_array_access ctx =
 	let show = hide_types ctx in
 	match load_type_def ctx null_pos ([],"ArrayAccess") with
 	| TClassDecl c ->
 		show();
 		if List.length c.cl_types <> 1 then assert false;
 		let pt = mk_mono() in
-		TInst (c,[v,pt]) , pt
+		TInst (c,[pt]) , pt
 	| _ ->
 		assert false
 
@@ -688,7 +688,7 @@ let t_iterator ctx =
 		show();
 		if List.length t.t_types <> 1 then assert false;
 		let pt = mk_mono() in
-		apply_params t.t_types [VNo,pt] t.t_type, pt
+		apply_params t.t_types [pt] t.t_type, pt
 	| _ ->
 		assert false
 
@@ -836,8 +836,8 @@ let type_type ctx tpath p =
 		let pub = is_parent c ctx.curclass in
 		let types = (match tparams with
 			| None ->
-				List.map (fun (v,_,t) ->
-					v, match follow t with
+				List.map (fun (_,t) ->
+					match follow t with
 					| TEnum _ -> mk_mono()
 					| _ -> t
 				) c.cl_types
@@ -855,7 +855,7 @@ let type_type ctx tpath p =
 		} in
 		mk (TTypeExpr (TClassDecl c)) (TType (t_tmp,types)) p
 	| TEnumDecl e ->
-		let types = (match tparams with None -> List.map (fun (v,_,_) -> v,mk_mono()) e.e_types | Some l -> l) in
+		let types = (match tparams with None -> List.map (fun _ -> mk_mono()) e.e_types | Some l -> l) in
 		let fl = PMap.fold (fun f acc ->
 			PMap.add f.ef_name {
 				cf_name = f.ef_name;
@@ -1380,7 +1380,7 @@ and type_switch ctx e cases def need_val p =
 			(try
 				let e = acc_get (type_ident ctx name false p true) p in
 				(match e.eexpr with
-				| TEnumField (e,_) -> Some (e, List.map (fun (v,_,_) -> v,mk_mono()) e.e_types)
+				| TEnumField (e,_) -> Some (e, List.map (fun _ -> mk_mono()) e.e_types)
 				| _ -> None)
 			with
 				Error (Custom _,_) -> lookup_enum l)
@@ -1589,15 +1589,15 @@ and type_access ctx e p get =
 		let e2 = type_expr ctx e2 in
 		unify ctx e2.etype (t_int ctx) e2.epos;
 		let pt = (try
-			let t , pt = t_array ctx VNo in
+			let t , pt = t_array ctx in
 			unify_raise ctx e1.etype t e1.epos;
 			pt
 		with Error (Unify _,_) -> try
-			let t , pt = t_array ctx (if get then VCo else VContra) in
+			let t , pt = t_array ctx in
 			unify_raise ctx e1.etype t e1.epos;
 			pt
 		with Error (Unify _,_) ->
-			let t, pt = t_array_access ctx (if get then VCo else VContra) in
+			let t, pt = t_array_access ctx in
 			unify ctx e1.etype t e1.epos;
 			pt
 		) in
@@ -1666,7 +1666,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 				t := t_dynamic);
 			e
 		) el in
-		let at , pt = t_array ctx VNo in
+		let at , pt = t_array ctx in
 		(match pt with
 		| TMono r -> r := Some (!t);
 		| _ -> assert false);
@@ -1808,7 +1808,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			let t = load_type ctx (pos e) t in
 			let name = (match follow t with
 				| TInst ({ cl_path = path },params) | TEnum ({ e_path = path },params) ->
-					List.iter (fun (_,pt) ->
+					List.iter (fun pt ->
 						if pt != t_dynamic then error "Catch class parameter must be Dynamic" p;
 					) params;
 					(match path with
@@ -1895,7 +1895,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		) in
 		mk (TCall (mk (TConst TSuper) t sp,el)) (t_void ctx) p
 	| ECall (e,el) ->
-		(match e with 
+		(match e with
 		| EField ((EConst (Ident "super"),_),_) , _ | EType ((EConst (Ident "super"),_),_) , _ -> ctx.super_call <- true
 		| _ -> ());
 		let e = type_expr ctx e in
@@ -1981,7 +1981,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		let t = load_type ctx (pos e) t in
 		let tname = (match follow t with
 		| TInst (_,params) | TEnum (_,params) ->
-			List.iter (fun (_,pt) ->
+			List.iter (fun pt ->
 				if pt != t_dynamic then error "Cast class parameter must be Dynamic" p;
 			) params;
 			(match follow t with
@@ -2036,7 +2036,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			let f = (match c.cl_constructor with Some f -> f | None -> error (s_type_path c.cl_path ^ " does not have a constructor") p) in
 			let t = apply_params c.cl_types params (field_type f) in
 			raise (Display t)
-		| _ -> 
+		| _ ->
 			error "Not a class" p)
 
 and type_function ctx t static constr f p =
@@ -2166,7 +2166,7 @@ let rec check_interface ctx c p intf params =
 				if not c.cl_interface then display_error ctx ("Field " ^ i ^ " needed by " ^ s_type_path intf.cl_path ^ " is missing") p
 	) intf.cl_fields;
 	List.iter (fun (i2,p2) ->
-		check_interface ctx c p i2 (List.map (fun (v,t) -> v, apply_params intf.cl_types params t) p2)
+		check_interface ctx c p i2 (List.map (apply_params intf.cl_types params) p2)
 	) intf.cl_implements
 
 let check_interfaces ctx c p () =
@@ -2179,12 +2179,12 @@ let check_interfaces ctx c p () =
 (* PASS 1 & 2 : Module and Class Structure *)
 
 let init_class ctx c p herits fields =
-	ctx.type_params <- List.map (fun (_,n,t) -> n,t) c.cl_types;
+	ctx.type_params <- c.cl_types;
 	c.cl_extern <- List.mem HExtern herits;
 	c.cl_interface <- List.mem HInterface herits;
 	set_heritance ctx c herits p;
-	let tthis = TInst (c,List.map (fun (v,_,t) -> v,t) c.cl_types) in
-	let rec extends_public c = 
+	let tthis = TInst (c,List.map snd c.cl_types) in
+	let rec extends_public c =
 		List.exists (fun (c,_) -> c.cl_path = (["haxe"],"Public") || extends_public c) c.cl_implements ||
 		match c.cl_super with
 		| None -> false
@@ -2248,11 +2248,10 @@ let init_class ctx c p herits fields =
 			) in
 			access, false, cf, delay
 		| FFun (name,doc,access,params,f) ->
-			let params = List.map (fun (v,n,flags) ->
+			let params = List.map (fun (n,flags) ->
 				match flags with
 				| [] ->
-					let _, n, t = type_type_params ctx c.cl_path p (v,n,[]) in
-					n, t
+					type_type_params ctx c.cl_path p (n,[])
 				| _ -> error "This notation is not allowed because it can't be checked" p
 			) params in
 			let ctx = { ctx with
@@ -2530,8 +2529,8 @@ let type_module ctx m tdecls loadp =
 			delays := !delays @ check_overriding ctx c p :: check_interfaces ctx c p :: init_class ctx c p d.d_flags d.d_data
 		| EEnum d ->
 			let e = get_enum d.d_name in
-			ctx.type_params <- List.map (fun (_,n,t) -> n, t) e.e_types;
-			let et = TEnum (e,List.map (fun (v,_,t) -> v ,t) e.e_types) in
+			ctx.type_params <- e.e_types;
+			let et = TEnum (e,List.map snd e.e_types) in
 			List.iter (fun (c,doc,t,p) ->
 				if c = "name" && Plugin.defined "js" then error "This identifier cannot be used in Javascript" p;
 				let t = (match t with
@@ -2543,7 +2542,7 @@ let type_module ctx m tdecls loadp =
 			) d.d_data
 		| ETypedef d ->
 			let t = get_tdef d.d_name in
-			ctx.type_params <- List.map (fun (_,n,t) -> n, t) t.t_types;
+			ctx.type_params <- t.t_types;
 			let tt = load_type ctx p d.d_data in
 			(match t.t_type with
 			| TMono r ->
@@ -2563,7 +2562,7 @@ let rec f9path p = {
 	tparams = List.map (fun c ->
 		match c with
 		| TPConst _ -> c
-		| TPType (v,t) -> TPType (v,f9t t)
+		| TPType t -> TPType (f9t t)
 	) p.tparams;
 }
 
@@ -2815,7 +2814,7 @@ let types ctx main excludes =
 				Not_found -> error ("Invalid -main : " ^ s_type_path cl ^ " does not have static function main") null_pos
 		) in
 		let path = ([],"@Main") in
-		let tmain = TInst (cmain,List.map (fun (v,_,t) -> v,t) cmain.cl_types) in
+		let tmain = TInst (cmain,List.map snd cmain.cl_types) in
 		let c = mk_class path null_pos None false in
 		let f = {
 			cf_name = "init";