Bläddra i källkod

lose type parameter on `TDynamic`, use the abstract instead

Simon Krajewski 5 år sedan
förälder
incheckning
1b5039f2d0
50 ändrade filer med 158 tillägg och 172 borttagningar
  1. 2 5
      src/codegen/codegen.ml
  2. 13 13
      src/codegen/gencommon/castDetect.ml
  3. 2 2
      src/codegen/gencommon/closuresToClass.ml
  4. 1 1
      src/codegen/gencommon/dynamicFieldAccess.ml
  5. 1 1
      src/codegen/gencommon/fixOverrides.ml
  6. 2 2
      src/codegen/gencommon/gencommon.ml
  7. 2 2
      src/codegen/gencommon/hardNullableSynf.ml
  8. 1 1
      src/codegen/gencommon/normalize.ml
  9. 1 1
      src/codegen/gencommon/realTypeParams.ml
  10. 1 1
      src/codegen/gencommon/reflectionCFs.ml
  11. 1 1
      src/codegen/genxml.ml
  12. 5 5
      src/codegen/overloads.ml
  13. 1 1
      src/compiler/displayOutput.ml
  14. 3 3
      src/context/display/displayEmitter.ml
  15. 4 4
      src/core/display/completionItem.ml
  16. 2 2
      src/core/error.ml
  17. 1 1
      src/core/json/genjson.ml
  18. 12 15
      src/core/tFunctions.ml
  19. 2 2
      src/core/tOther.ml
  20. 3 3
      src/core/tPrinting.ml
  21. 1 1
      src/core/tType.ml
  22. 14 13
      src/core/tUnification.ml
  23. 2 2
      src/generators/gencpp.ml
  24. 14 14
      src/generators/gencs.ml
  25. 1 1
      src/generators/genhl.ml
  26. 2 2
      src/generators/genhxold.ml
  27. 12 12
      src/generators/genjava.ml
  28. 1 1
      src/generators/genjs.ml
  29. 1 1
      src/generators/genjvm.ml
  30. 2 2
      src/generators/genlua.ml
  31. 1 1
      src/generators/genneko.ml
  32. 2 2
      src/generators/genphp7.ml
  33. 5 5
      src/generators/genpy.ml
  34. 2 2
      src/generators/genswf.ml
  35. 2 2
      src/generators/genswf9.ml
  36. 1 1
      src/macro/eval/evalJit.ml
  37. 1 1
      src/macro/eval/evalMain.ml
  38. 4 7
      src/macro/macroApi.ml
  39. 1 1
      src/optimization/analyzerTexpr.ml
  40. 6 9
      src/optimization/dce.ml
  41. 1 1
      src/typing/fields.ml
  42. 4 4
      src/typing/forLoop.ml
  43. 3 3
      src/typing/generic.ml
  44. 2 2
      src/typing/matcher.ml
  45. 1 1
      src/typing/nullSafety.ml
  46. 2 5
      src/typing/typeload.ml
  47. 1 1
      src/typing/typeloadCheck.ml
  48. 1 1
      src/typing/typeloadFields.ml
  49. 7 7
      src/typing/typer.ml
  50. 1 1
      src/typing/typerDisplay.ml

+ 2 - 5
src/codegen/codegen.ml

@@ -103,11 +103,8 @@ let update_cache_dependencies t =
 			| _ -> ())
 		| TLazy f ->
 			check_t m (lazy_type f)
-		| TDynamic t ->
-			if t == t_dynamic then
-				()
-			else
-				check_t m t
+		| TDynamic ->
+			()
 	and check_field m cf =
 		check_t m cf.cf_type
 	in

+ 13 - 13
src/codegen/gencommon/castDetect.ml

@@ -185,8 +185,8 @@ let rec type_eq gen param a b =
 			) l1 l2
 		with
 			Unify_error l -> Type.error (cannot_unify a b :: l))
-	| TDynamic a , TDynamic b ->
-		type_eq gen param a b
+	| TDynamic, TDynamic ->
+		()
 	| TAnon a1, TAnon a2 ->
 		(try
 			PMap.iter (fun n f1 ->
@@ -251,8 +251,8 @@ let rec is_unsafe_cast gen to_t from_t =
 			false
 		| TMono _, _
 		| _, TMono _
-		| TDynamic _, _
-		| _, TDynamic _ ->
+		| TDynamic, _
+		| _, TDynamic ->
 			false
 		| TAnon _, _
 		| _, TAnon _ ->
@@ -285,7 +285,7 @@ let do_unsafe_cast gen from_t to_t e	=
 			| TEnum(e, _) -> e.e_path
 			| TType(t, _) -> t.t_path
 			| TAbstract(a, _) -> a.a_path
-			| TDynamic _ -> ([], "Dynamic")
+			| TDynamic -> ([], "Dynamic")
 			| _ -> raise Not_found
 	in
 	match gen.gfollow#run_f from_t, gen.gfollow#run_f to_t with
@@ -396,18 +396,18 @@ let rec handle_cast gen e real_to_t real_from_t =
 				(* potential unsafe cast *)
 				(do_unsafe_cast ())
 		| TMono _, TMono _
-		| TMono _, TDynamic _
-		| TDynamic _, TDynamic _
-		| TDynamic _, TMono _ ->
+		| TMono _, TDynamic
+		| TDynamic, TDynamic
+		| TDynamic, TMono _ ->
 			e
 		| TMono _, _
-		| TDynamic _, _
+		| TDynamic, _
 		| TAnon _, _ when gen.gneeds_box real_from_t ->
 			mk_cast false to_t e
 		| TMono _, _
-		| TDynamic _, _ -> e
+		| TDynamic, _ -> e
 		| _, TMono _
-		| _, TDynamic _ -> mk_cast false to_t e
+		| _, TDynamic -> mk_cast false to_t e
 		| TAnon (a_to), TAnon (a_from) ->
 			if a_to == a_from then
 				e
@@ -596,7 +596,7 @@ let choose_ctor gen cl tparams etl maybe_empty_t p =
 		| Some(sup,stl) -> get_changed_stl sup (List.map (apply_params c.cl_params tl) stl)
 	in
 	let ret_tparams = List.map (fun t -> match follow t with
-		| TDynamic _ | TMono _ -> t_empty
+		| TDynamic | TMono _ -> t_empty
 		| _ -> t) tparams
 	in
 	let ret_stl = get_changed_stl cl ret_tparams in
@@ -903,7 +903,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 					because of differences on how <Dynamic> is handled on the platforms, this is a hack to be able to
 					correctly use class field type parameters with RealTypeParams
 				*)
-				let cf_params = List.map (fun t -> match follow t with | TDynamic _ -> t_empty | _ -> t) _params in
+				let cf_params = List.map (fun t -> match follow t with | TDynamic -> t_empty | _ -> t) _params in
 				let t = apply_params en.e_params (gen.greal_type_param (TEnumDecl en) cf_params) actual_t in
 				let t = apply_params efield.ef_params (List.map (fun _ -> t_dynamic) efield.ef_params) t in
 

+ 2 - 2
src/codegen/gencommon/closuresToClass.ml

@@ -283,8 +283,8 @@ let rec get_type_params acc t =
 			List.filter (fun t -> not (List.memq t acc)) (cl :: params) @ acc;
 		| TFun (params,tret) ->
 			List.fold_left get_type_params acc ( tret :: List.map (fun (_,_,t) -> t) params )
-		| TDynamic t ->
-			(match t with | TDynamic _ -> acc | _ -> get_type_params acc t)
+		| TDynamic ->
+			acc
 		| TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 				get_type_params acc ( Abstract.get_underlying_type a pl)
 		| TAnon a ->

+ 1 - 1
src/codegen/gencommon/dynamicFieldAccess.ml

@@ -99,7 +99,7 @@ let configure gen (is_dynamic:texpr->Type.tfield_access->bool) (change_expr:texp
 
 		| TCall ({ eexpr = TField (_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "field" })) }, [obj; { eexpr = TConst (TString field) }]) ->
 			let t = match gen.greal_type obj.etype with
-			| TDynamic _ | TAnon _ | TMono _ -> t_dynamic
+			| TDynamic | TAnon _ | TMono _ -> t_dynamic
 			| t -> t
 			in
 			change_expr (mk_field_access gen { obj with etype = t } field obj.epos) (run obj) field None false

+ 1 - 1
src/codegen/gencommon/fixOverrides.ml

@@ -98,7 +98,7 @@ let run ~explicit_fn_name ~get_vmtype gen =
 								(* different return types are the trickiest cases to deal with *)
 								(* check for covariant return type *)
 								let is_covariant = match follow r1, follow r2 with
-									| _, TDynamic _ -> false
+									| _, TDynamic -> false
 									| r1, r2 -> try
 										unify r1 r2;
 										if like_int r1 then like_int r2 else true

+ 2 - 2
src/codegen/gencommon/gencommon.ml

@@ -1080,7 +1080,7 @@ let rec replace_mono t =
 		List.iter (fun (_,_,t) -> replace_mono t) args;
 		replace_mono ret
 	| TAnon _
-	| TDynamic _ -> ()
+	| TDynamic -> ()
 	| TLazy f ->
 		replace_mono (lazy_type f)
 
@@ -1248,7 +1248,7 @@ let rec field_access gen (t:t) (field:string) : (tfield_access) =
 		| _ when PMap.mem field gen.gbase_class_fields ->
 			let cf = PMap.find field gen.gbase_class_fields in
 			FClassField(gen.gclasses.cl_dyn, [t_dynamic], gen.gclasses.cl_dyn, cf, false, cf.cf_type, cf.cf_type)
-		| TDynamic t -> FDynamicField t
+		| TDynamic -> FDynamicField t_dynamic
 		| TMono _ -> FDynamicField t_dynamic
 		| _ -> FNotFound
 

+ 2 - 2
src/codegen/gencommon/hardNullableSynf.ml

@@ -83,9 +83,9 @@ let configure gen unwrap_null wrap_val null_to_dynamic has_value opeq_handler =
 	let handle_unwrap to_t e =
 		let e_null_t = get (is_null_t e.etype) in
 		match gen.greal_type to_t with
-			| TDynamic _ | TMono _ | TAnon _ ->
+			| TDynamic | TMono _ | TAnon _ ->
 				(match e_null_t with
-					| TDynamic _ | TMono _ | TAnon _ ->
+					| TDynamic | TMono _ | TAnon _ ->
 						gen.ghandle_cast to_t e_null_t (unwrap_null e)
 					| _ -> null_to_dynamic e
 				)

+ 1 - 1
src/codegen/gencommon/normalize.ml

@@ -58,7 +58,7 @@ let rec filter_param (stack:t list) t =
 		mk_anon ~fields a.a_status
 	| TFun(args,ret) ->
 		TFun(List.map (fun (n,o,t) -> (n,o,filter_param stack t)) args, filter_param stack ret)
-	| TDynamic _ ->
+	| TDynamic ->
 		t
 	| TLazy f ->
 		filter_param stack (lazy_type f)

+ 1 - 1
src/codegen/gencommon/realTypeParams.ml

@@ -505,7 +505,7 @@ struct
 				| TInst (cl,_) -> cl.cl_path
 				| TEnum (e,_) -> e.e_path
 				| TAbstract (a,_) -> a.a_path
-				| TMono _ | TDynamic _ -> ([], "Dynamic")
+				| TMono _ | TDynamic -> ([], "Dynamic")
 				| _ -> Globals.die "" __LOC__
 			in
 			List.map (fun (cf, t_cl, t_cf) ->

+ 1 - 1
src/codegen/gencommon/reflectionCFs.ml

@@ -972,7 +972,7 @@ let implement_get_set ctx cl =
 			if is_float then
 				List.filter (fun (_,cf) -> (* TODO: maybe really apply_params in cf.cf_type. The benefits would be limited, though *)
 					match follow (ctx.rcf_gen.greal_type (ctx.rcf_gen.gfollow#run_f cf.cf_type)) with
-						| TDynamic _ | TMono _
+						| TDynamic | TMono _
 						| TInst ({ cl_kind = KTypeParameter _ }, _) -> true
 						| t when like_float t && not (like_i64 t) -> true
 						| _ -> false

+ 1 - 1
src/codegen/genxml.ml

@@ -122,7 +122,7 @@ let rec gen_type ?(values=None) t =
 		) args in
 		node "f" (("a",names) :: values) (List.map gen_type (args @ [r]))
 	| TAnon a -> node "a" [] (pmap (fun f -> gen_field [] { f with cf_flags = unset_flag f.cf_flags (int_of_class_field_flag CfPublic) }) a.a_fields)
-	| TDynamic t2 -> node "d" [] (if t == t2 then [] else [gen_type t2])
+	| TDynamic -> node "d" [] []
 	| TLazy f -> gen_type (lazy_type f)
 
 and gen_type_decl n t pl =

+ 5 - 5
src/codegen/overloads.ml

@@ -136,7 +136,7 @@ struct
 			| Some t -> simplify_t t
 			| None -> t_dynamic)
 		| TAnon _ -> t_dynamic
-		| TDynamic _ -> t
+		| TDynamic -> t
 		| TLazy f -> simplify_t (lazy_type f)
 		| TFun _ -> t
 
@@ -189,13 +189,13 @@ struct
 		| TEnum(ef,tlf), TEnum(ea, tla) ->
 			if ef != ea then raise Not_found;
 			(cacc, rate_tp tlf tla)
-		| TDynamic _, TDynamic _ ->
+		| TDynamic, TDynamic ->
 			(cacc, 0)
-		| TDynamic _, _ ->
+		| TDynamic, _ ->
 			(max_int, 0) (* a function with dynamic will always be worst of all *)
-		| TAbstract(a, _), TDynamic _ when Meta.has Meta.CoreType a.a_meta && a.a_path <> ([],"Null") ->
+		| TAbstract(a, _), TDynamic when Meta.has Meta.CoreType a.a_meta && a.a_path <> ([],"Null") ->
 			(cacc + 2, 0) (* a dynamic to a basic type will have an "unboxing" penalty *)
-		| _, TDynamic _ ->
+		| _, TDynamic ->
 			(cacc + 1, 0)
 		| TAbstract({ a_path = [], "Null" }, [tf]), TAbstract({ a_path = [], "Null" }, [ta]) ->
 			rate_conv (cacc+0) tf ta

+ 1 - 1
src/compiler/displayOutput.ml

@@ -395,7 +395,7 @@ let promote_type_hints tctx =
 		| TType(({t_name_pos = pn;t_path = (_,name)}),_)
 		| TAbstract(({a_name_pos = pn;a_path = (_,name)}),_) ->
 			md.m_type_hints <- (p,pn) :: md.m_type_hints;
-		| TDynamic _ -> ()
+		| TDynamic -> ()
 		| TFun _ | TAnon _ -> ()
 	in
 	List.iter explore_type_hint tctx.g.type_hints

+ 3 - 3
src/context/display/displayEmitter.ml

@@ -45,8 +45,8 @@ let rec display_type ctx t p =
 		display_module_type ctx (module_type_of_type t) p
 	with Exit ->
 		match follow t,follow !t_dynamic_def with
-		| _,TDynamic _ -> () (* sanity check in case it's still t_dynamic *)
-		| TDynamic _,_ -> display_type ctx !t_dynamic_def p
+		| _,TDynamic -> () (* sanity check in case it's still t_dynamic *)
+		| TDynamic,_ -> display_type ctx !t_dynamic_def p
 		| _ ->
 			match dm.dms_kind with
 			| DMHover ->
@@ -81,7 +81,7 @@ let raise_position_of_type t =
 				| TMono r -> (match r.tm_type with None -> raise_positions [null_pos] | Some t -> follow_null t)
 				| TLazy f -> follow_null (lazy_type f)
 				| TAbstract({a_path = [],"Null"},[t]) -> follow_null t
-				| TDynamic _ -> !t_dynamic_def
+				| TDynamic -> !t_dynamic_def
 				| _ -> t
 		in
 		try

+ 4 - 4
src/core/display/completionItem.ml

@@ -372,7 +372,7 @@ module CompletionType = struct
 		| CTAbstract of ct_path_with_params
 		| CTFunction of ct_function
 		| CTAnonymous of ct_anonymous
-		| CTDynamic of t option
+		| CTDynamic
 
 	let rec generate_path_with_params ctx pwp = jobject [
 		"path",jobject [
@@ -424,7 +424,7 @@ module CompletionType = struct
 			| CTAbstract pwp -> "TAbstract",Some (generate_path_with_params ctx pwp)
 			| CTFunction ctf -> "TFun",Some (generate_function ctx ctf)
 			| CTAnonymous cta -> "TAnonymous",Some (generate_anon ctx cta)
-			| CTDynamic cto -> "TDynamic",Option.map (generate_type ctx) cto;
+			| CTDynamic -> "TDynamic",None
 		in
 		generate_adt ctx None name args
 
@@ -489,8 +489,8 @@ module CompletionType = struct
 					ct_fields = PMap.fold (fun cf acc -> afield cf :: acc) an.a_fields [];
 					ct_status = !(an.a_status);
 				}
-			| TDynamic t ->
-				CTDynamic (if t == t_dynamic then None else Some (from_type PMap.empty t))
+			| TDynamic ->
+				CTDynamic
 		in
 		from_type values t
 end

+ 2 - 2
src/core/error.ml

@@ -187,8 +187,8 @@ module BetterErrors = struct
 					let fl = PMap.fold (fun f acc -> ((if Meta.has Meta.Optional f.cf_meta then " ?" else " ") ^ f.cf_name) :: acc) a.a_fields [] in
 					"{" ^ String.concat "," fl ^ " }"
 			end
-		| TDynamic t2 ->
-			"Dynamic" ^ s_type_params ctx (if t == t2 then [] else [t2])
+		| TDynamic ->
+			"Dynamic"
 		| TLazy f ->
 			s_type ctx (lazy_type f)
 

+ 1 - 1
src/core/json/genjson.ml

@@ -213,7 +213,7 @@ let rec generate_type ctx t =
 			let t = lazy_type f in
 			(* return_partial_type := false; *)
 			loop t
-		| TDynamic t -> "TDynamic",Some (if t == t_dynamic then jnull else generate_type ctx t)
+		| TDynamic -> "TDynamic",Some jnull
 		| TInst(c,tl) -> "TInst",Some (generate_type_path_with_params ctx c.cl_module.m_path c.cl_path tl c.cl_meta)
 		| TEnum(en,tl) -> "TEnum",Some (generate_type_path_with_params ctx en.e_module.m_path en.e_path tl en.e_meta)
 		| TType(td,tl) -> "TType",Some (generate_type_path_with_params ctx td.t_module.m_path td.t_path tl td.t_meta)

+ 12 - 15
src/core/tFunctions.ml

@@ -79,7 +79,7 @@ let null t p = mk (TConst TNull) t p
 
 let mk_mono() = TMono (!monomorph_create_ref ())
 
-let rec t_dynamic = TDynamic t_dynamic
+let rec t_dynamic = TDynamic
 
 let mk_anon ?fields status =
 	let fields = match fields with Some fields -> fields | None -> PMap.empty in
@@ -262,8 +262,8 @@ let map loop t =
 		let ft = lazy_type f in
 		let ft2 = loop ft in
 		if ft == ft2 then t else ft2
-	| TDynamic t2 ->
-		if t == t2 then	t else TDynamic (loop t2)
+	| TDynamic ->
+		t
 
 let iter loop t =
 	match t with
@@ -289,8 +289,8 @@ let iter loop t =
 	| TLazy f ->
 		let ft = lazy_type f in
 		loop ft
-	| TDynamic t2 ->
-		if t != t2 then	loop t2
+	| TDynamic ->
+		()
 
 let duplicate t =
 	let monos = ref [] in
@@ -416,11 +416,8 @@ let apply_params ?stack cparams params t =
 				t
 			else
 				ft2
-		| TDynamic t2 ->
-			if t == t2 then
-				t
-			else
-				TDynamic (loop t2)
+		| TDynamic ->
+			t
 	in
 	loop t
 
@@ -462,7 +459,7 @@ let follow_once t =
 		(match r.tm_type with
 		| None -> t
 		| Some t -> t)
-	| TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic _ ->
+	| TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic ->
 		t
 	| TType (t,tl) ->
 		apply_params t.t_params tl t.t_type
@@ -497,7 +494,7 @@ let rec ambiguate_funs t =
 	    TAbstract (a, List.map ambiguate_funs pl)
 	| TType (a, pl) ->
 	    TType (a, List.map ambiguate_funs pl)
-	| TDynamic _ -> t
+	| TDynamic -> t
 	| TAnon a ->
 	    TAnon { a with a_fields =
 		    PMap.map (fun af -> { af with cf_type =
@@ -569,7 +566,7 @@ let rec has_mono t = match t with
 		(match r.tm_type with None -> true | Some t -> has_mono t)
 	| TInst(_,pl) | TEnum(_,pl) | TAbstract(_,pl) | TType(_,pl) ->
 		List.exists has_mono pl
-	| TDynamic _ ->
+	| TDynamic ->
 		false
 	| TFun(args,r) ->
 		has_mono r || List.exists (fun (_,_,t) -> has_mono t) args
@@ -733,7 +730,7 @@ let quick_field t n =
 			end
 		| _ ->
 			FAnon (PMap.find n a.a_fields))
-	| TDynamic _ ->
+	| TDynamic ->
 		FDynamic n
 	| TEnum _  | TMono _ | TAbstract _ | TFun _ ->
 		raise Not_found
@@ -780,7 +777,7 @@ let resolve_typedef t =
 *)
 let type_has_meta t m =
 	match t with
-		| TMono _ | TFun _ | TAnon _ | TDynamic _ | TLazy _ -> false
+		| TMono _ | TFun _ | TAnon _ | TDynamic | TLazy _ -> false
 		| TEnum ({ e_meta = metadata }, _)
 		| TInst ({ cl_meta = metadata }, _)
 		| TType ({ t_meta = metadata }, _)

+ 2 - 2
src/core/tOther.ml

@@ -52,8 +52,8 @@ module TExprToExpr = struct
 					} :: acc
 				) a.a_fields [])
 			end
-		| (TDynamic t2) as t ->
-			tpath ([],"Dynamic") ([],"Dynamic") (if t == t_dynamic then [] else [tparam t2])
+		| TDynamic ->
+			tpath ([],"Dynamic") ([],"Dynamic") []
 		| TLazy f ->
 			convert_type (lazy_type f)
 

+ 3 - 3
src/core/tPrinting.ml

@@ -19,7 +19,7 @@ let rec s_type_kind t =
 	| TAbstract(a,tl) -> Printf.sprintf "TAbstract(%s, [%s])" (s_type_path a.a_path) (map tl)
 	| TFun(tl,r) -> Printf.sprintf "TFun([%s], %s)" (String.concat ", " (List.map (fun (n,b,t) -> Printf.sprintf "%s%s:%s" (if b then "?" else "") n (s_type_kind t)) tl)) (s_type_kind r)
 	| TAnon an -> "TAnon"
-	| TDynamic t2 -> "TDynamic"
+	| TDynamic -> "TDynamic"
 	| TLazy _ -> "TLazy"
 
 let s_module_type_kind = function
@@ -82,8 +82,8 @@ let rec s_type ctx t =
 				let fl = PMap.fold (fun f acc -> ((if Meta.has Meta.Optional f.cf_meta then " ?" else " ") ^ f.cf_name ^ " : " ^ s_type ctx f.cf_type) :: acc) a.a_fields [] in
 				"{" ^ String.concat "," fl ^ " }"
 		end
-	| TDynamic t2 ->
-		"Dynamic" ^ s_type_params ctx (if t == t2 then [] else [t2])
+	| TDynamic ->
+		"Dynamic"
 	| TLazy f ->
 		s_type ctx (lazy_type f)
 

+ 1 - 1
src/core/tType.ml

@@ -39,7 +39,7 @@ type t =
 	| TType of tdef * tparams
 	| TFun of tsignature
 	| TAnon of tanon
-	| TDynamic of t
+	| TDynamic
 	| TLazy of tlazy ref
 	| TAbstract of tabstract * tparams
 

+ 14 - 13
src/core/tUnification.ml

@@ -245,11 +245,8 @@ let rec link e a b =
 		| TEnum (_,tl) -> List.exists loop tl
 		| TInst (_,tl) | TType (_,tl) | TAbstract (_,tl) -> List.exists loop tl
 		| TFun (tl,t) -> List.exists (fun (_,_,t) -> loop t) tl || loop t
-		| TDynamic t2 ->
-			if t == t2 then
-				false
-			else
-				loop t2
+		| TDynamic ->
+			false
 		| TLazy f ->
 			loop (lazy_type f)
 		| TAnon a ->
@@ -270,8 +267,8 @@ let rec link e a b =
 	end
 
 let link_dynamic a b = match follow a,follow b with
-	| TMono r,TDynamic _ -> Monomorph.bind r b
-	| TDynamic _,TMono r -> Monomorph.bind r a
+	| TMono r,TDynamic -> Monomorph.bind r b
+	| TDynamic,TMono r -> Monomorph.bind r a
 	| _ -> ()
 
 let fast_eq_check type_param_check a b =
@@ -502,8 +499,8 @@ let rec type_eq uctx a b =
 				let msg = if !i = 0 then Invalid_return_type else Invalid_function_argument(!i,List.length l1) in
 				error (cannot_unify a b :: msg :: l)
 		)
-	| TDynamic a , TDynamic b ->
-		type_eq uctx a b
+	| TDynamic, TDynamic ->
+		()
 	| TAbstract (a1,tl1) , TAbstract (a2,tl2) ->
 		if a1 != a2 && not (param = EqCoreType && a1.a_path = a2.a_path) then error [cannot_unify a b];
 		type_eq_params uctx a b tl1 tl2
@@ -784,11 +781,15 @@ let rec unify (uctx : unification_context) a b =
 		with Not_found ->
 			error [has_no_field a "new"]
 		end
-	| TDynamic t , _ ->
+	| TDynamic, _ ->
+		()
+	| _ , TDynamic ->
+		()
+	| TAbstract({a_path=([],"Dynamic")},[t]),_ ->
 		if t == a then
 			()
 		else (match b with
-		| TDynamic t2 ->
+		| TAbstract({a_path=([],"Dynamic")},[t2]) ->
 			if t2 != b then
 				(try
 					type_eq {uctx with equality_kind = EqRightDynamic} t t2
@@ -798,11 +799,11 @@ let rec unify (uctx : unification_context) a b =
 			unify_from uctx a b bb tl
 		| _ ->
 			error [cannot_unify a b])
-	| _ , TDynamic t ->
+	| _ , TAbstract({a_path=([],"Dynamic")},[t]) ->
 		if t == b then
 			()
 		else (match a with
-		| TDynamic t2 ->
+		| TAbstract({a_path=([],"Dynamic")},[t2]) ->
 			if t2 != a then
 				(try
 					type_eq {uctx with equality_kind = EqRightDynamic} t t2

+ 2 - 2
src/generators/gencpp.ml

@@ -805,7 +805,7 @@ and type_string_suff suffix haxe_type remap =
       | EnumStatics e -> type_string_suff suffix (TEnum (e,List.map snd e.e_params))
       | _ -> "Dynamic"  ^ suffix )
       *)
-   | TDynamic haxe_type -> "Dynamic" ^ suffix
+   | TDynamic -> "Dynamic" ^ suffix
    | TLazy func -> type_string_suff suffix (lazy_type func) remap
    | TAbstract (abs,pl) when abs.a_impl <> None ->
       type_string_suff suffix (Abstract.get_underlying_type abs pl) remap
@@ -1765,7 +1765,7 @@ let rec cpp_type_of stack ctx haxe_type =
 
       | TFun _ -> TCppObject
       | TAnon _ -> TCppObject
-      | TDynamic _ -> TCppDynamic
+      | TDynamic -> TCppDynamic
       | TLazy func -> cpp_type_of stack ctx (lazy_type func)
       )
    end

+ 14 - 14
src/generators/gencs.ml

@@ -97,7 +97,7 @@ let is_exactly_bool gen t =
 
 let is_dynamic gen t =
 	match follow (gen.greal_type t) with
-		| TDynamic _ -> true
+		| TDynamic -> true
 		| _ -> false
 
 let is_pointer gen t =
@@ -913,7 +913,7 @@ let generate con =
 
 		let has_tdyn tl =
 			List.exists (fun t -> match follow t with
-			| TDynamic _ | TMono _ -> true
+			| TDynamic | TMono _ -> true
 			| _ -> false
 		) tl
 		in
@@ -1009,11 +1009,11 @@ let generate con =
 				| true, TInst _
 				| true, TEnum _
 				| true, TAbstract _ when is_cs_basic_type t_changed -> t
-				| true, TDynamic _ -> t
+				| true, TDynamic -> t
 				| true, x ->
 					dynamic_anon
 			in
-			if is_hxgeneric && (erase_generics || List.exists (fun t -> match follow t with | TDynamic _ -> true | _ -> false) tl) then
+			if is_hxgeneric && (erase_generics || List.exists (fun t -> match follow t with | TDynamic -> true | _ -> false) tl) then
 				List.map (fun _ -> t_dynamic) tl
 			else
 				List.map ret tl
@@ -1023,7 +1023,7 @@ let generate con =
 		and change_param_type = change_param_type [] in
 
 		let is_dynamic t = match real_type t with
-			| TMono _ | TDynamic _
+			| TMono _ | TDynamic
 			| TInst({ cl_kind = KTypeParameter _ }, _) -> true
 			| TAnon anon ->
 				(match !(anon.a_status) with
@@ -1092,7 +1092,7 @@ let generate con =
 					(match !(anon.a_status) with
 						| Statics _ | EnumStatics _ -> "System.Type"
 						| _ -> "object")
-				| TDynamic _ -> "object"
+				| TDynamic -> "object"
 				| TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) ->
 					t_s (Abstract.get_underlying_type a pl)
 				(* No Lazy type nor Function type made. That's because function types will be at this point be converted into other types *)
@@ -2270,7 +2270,7 @@ let generate con =
 					let is_override = is_override || match cf.cf_name, follow cf.cf_type with
 						| "Equals", TFun([_,_,targ], tret) ->
 							(match follow targ, follow tret with
-								| TDynamic _, TAbstract({ a_path = ([], "Bool") }, []) -> true
+								| TDynamic, TAbstract({ a_path = ([], "Bool") }, []) -> true
 								| _ -> false)
 						| "GetHashCode", TFun([],_) -> true
 						| _ -> false
@@ -2955,7 +2955,7 @@ let generate con =
 			)
 			(fun v t has_value ->
 				match has_value, real_type v.etype with
-					| true, TDynamic _ | true, TAnon _ | true, TMono _ ->
+					| true, TDynamic | true, TAnon _ | true, TMono _ ->
 						{
 							eexpr = TCall(mk_static_field_access_infer null_t "ofDynamic" v.epos [t], [mk_tp t v.epos; v]);
 							etype = TInst(null_t, [t]);
@@ -3024,7 +3024,7 @@ let generate con =
 		let rcf_static_insert, rcf_static_remove =
 			let get_specialized_postfix t = match t with
 				| TAbstract({a_path = [],("Float" | "Int" as name)}, _) -> name
-				| TAnon _ | TDynamic _ -> "Dynamic"
+				| TAnon _ | TDynamic -> "Dynamic"
 				| _ -> print_endline (debug_type t); die "" __LOC__
 			in
 			(fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) null_pos []),
@@ -3161,7 +3161,7 @@ let generate con =
 			match e.eexpr with
 				| TArray(e1, e2) ->
 					(match follow e1.etype with
-						| TDynamic _ | TAnon _ | TMono _ -> true
+						| TDynamic | TAnon _ | TMono _ -> true
 						| TInst({ cl_kind = KTypeParameter _ }, _) -> true
 						| TInst(c,p) when erase_generics && is_hxgeneric (TClassDecl c) && is_hxgen (TClassDecl c) -> (match c.cl_path with
 							| [],"String"
@@ -3169,7 +3169,7 @@ let generate con =
 							| _ ->
 								true)
 						| _ -> match binop, change_param_type (t_to_md e1.etype) [e.etype] with
-							| Some(Ast.OpAssignOp _), ([TDynamic _] | [TAnon _]) ->
+							| Some(Ast.OpAssignOp _), ([TDynamic] | [TAnon _]) ->
 								true
 							| _ -> false)
 				| _ -> die "" __LOC__
@@ -3224,7 +3224,7 @@ let generate con =
 
 		let should_handle_opeq t =
 			match real_type t with
-				| TDynamic _ | TAnon _ | TMono _
+				| TDynamic | TAnon _ | TMono _
 				| TInst( { cl_kind = KTypeParameter _ }, _ )
 				| TInst( { cl_path = (["haxe";"lang"], "Null") }, _ ) -> true
 				| _ -> false
@@ -3278,8 +3278,8 @@ let generate con =
 			(fun e1 e2 ->
 				let is_basic = is_cs_basic_type (follow e1.etype) || is_cs_basic_type (follow e2.etype) in
 				let is_ref = if is_basic then false else match follow e1.etype, follow e2.etype with
-					| TDynamic _, _
-					| _, TDynamic _
+					| TDynamic, _
+					| _, TDynamic
 					| TInst( { cl_path = ([], "String") }, [] ), _
 					| _, TInst( { cl_path = ([], "String") }, [] )
 					| TInst( { cl_kind = KTypeParameter _ }, [] ), _

+ 1 - 1
src/generators/genhl.ml

@@ -421,7 +421,7 @@ let rec to_type ?tref ctx t =
 			Array.iteri (fun i (n,_,_) -> vp.vindex <- PMap.add n i vp.vindex) vp.vfields;
 			t
 		)
-	| TDynamic _ ->
+	| TDynamic ->
 		HDyn
 	| TEnum (e,_) ->
 		enum_type ~tref ctx e

+ 2 - 2
src/generators/genhxold.ml

@@ -104,8 +104,8 @@ let generate_type com t =
 			"{" ^ String.concat ", " fields ^ "}"
 		| TLazy f ->
 			stype (lazy_type f)
-		| TDynamic t2 ->
-			if t == t2 then "Dynamic" else "Dynamic<" ^ stype t2 ^ ">"
+		| TDynamic ->
+			"Dynamic"
 		| TFun ([],ret) ->
 			"() -> " ^ ftype ret
 		| TFun (args,ret) ->

+ 12 - 12
src/generators/genjava.ml

@@ -114,7 +114,7 @@ let rec t_has_type_param t = match follow t with
 
 let is_dynamic gen t =
 	match follow (gen.greal_type t) with
-		| TDynamic _ -> true
+		| TDynamic -> true
 		| _ -> false
 
 let is_type_param t = ExtType.is_type_param (follow t)
@@ -807,7 +807,7 @@ struct
 						let is_assign = match op with Ast.OpAssignOp _ -> true | _ -> false in
 						let mk_to_string e = { e with eexpr = TCall( mk_static_field_access_infer runtime_cl "toString" e.epos [], [run e] ); etype = gen.gcon.basic.tstring	} in
 						let check_cast e = match gen.greal_type e.etype with
-							| TDynamic _
+							| TDynamic
 							| TAbstract({ a_path = ([], "Float") }, [])
 							| TAbstract({ a_path = ([], "Single") }, []) ->
 									mk_to_string e
@@ -880,7 +880,7 @@ let rec handle_throws gen cf =
 					Type.iter iter e;
 					match follow (run_follow gen v.v_type) with
 						| TInst({ cl_path = ["java";"lang"],"Throwable" },_)
-						| TDynamic _ ->
+						| TDynamic ->
 							needs_check_block := false
 						| TInst(c,_) when is_checked_exc c ->
 							throws := PMap.add c.cl_path c !throws
@@ -1005,7 +1005,7 @@ let generate con =
 	let ti64 = match ( get_type gen (["java"], "Int64") ) with | TAbstractDecl a -> TAbstract(a,[]) | _ -> die "" __LOC__ in
 
 	let has_tdynamic params =
-		List.exists (fun e -> match run_follow gen e with | TDynamic _ -> true | _ -> false) params
+		List.exists (fun e -> match run_follow gen e with | TDynamic -> true | _ -> false) params
 	in
 
 	(*
@@ -1206,7 +1206,7 @@ let generate con =
 	in
 
 	let is_dynamic t = match real_type t with
-		| TMono _ | TDynamic _
+		| TMono _ | TDynamic
 		| TInst({ cl_kind = KTypeParameter _ }, _) -> true
 		| TAnon anon ->
 			(match !(anon.a_status) with
@@ -1276,7 +1276,7 @@ let generate con =
 								path_s_import pos (["java";"lang"], "Class") []
 						| _ ->
 								path_s_import pos (["java";"lang"], "Object") [])
-					| TDynamic _ ->
+					| TDynamic ->
 							path_s_import pos (["java";"lang"], "Object") []
 				(* No Lazy type nor Function type made. That's because function types will be at this point be converted into other types *)
 				| _ -> if !strict_mode then begin trace ("[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]"); die "" __LOC__ end else "[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]"
@@ -1310,7 +1310,7 @@ let generate con =
 			| TType ({ t_path = [],"Single" },[])
 			| TAbstract ({ a_path = [],"Single" },[]) ->
 					path_s_import pos (["java";"lang"], "Float") []
-			| TDynamic _ -> "?"
+			| TDynamic -> "?"
 			| TInst (cl, params) -> t_s stack pos (TInst(cl, change_param_type (TClassDecl cl) params))
 			| TType (cl, params) -> t_s stack pos (TType(cl, change_param_type (TTypeDecl cl) params))
 			| TEnum (e, params) -> t_s stack pos (TEnum(e, change_param_type (TEnumDecl e) params))
@@ -1958,7 +1958,7 @@ let generate con =
 						(match cf.cf_type with
 							| TFun([_,_,t], ret) ->
 								(match (real_type t, real_type ret) with
-									| TDynamic _, TAbstract ({ a_path = ([], "Bool") },[])
+									| TDynamic, TAbstract ({ a_path = ([], "Bool") },[])
 									| TAnon _, TAbstract ({ a_path = ([], "Bool") },[]) -> true
 									| _ -> has_class_field_flag cf CfOverride
 								)
@@ -2117,7 +2117,7 @@ let generate con =
 		let params, _ = get_string_params cl.cl_params in
 		let cl_p_to_string (c,p) =
 			let p = List.map (fun t -> match follow t with
-				| TMono _ | TDynamic _ -> t_empty
+				| TMono _ | TDynamic -> t_empty
 				| _ -> t) p
 			in
 			path_param_s cl.cl_pos (TClassDecl c) c.cl_path p c.cl_meta
@@ -2330,7 +2330,7 @@ let generate con =
 	let get_specialized_postfix t = match t with
 		| TAbstract({a_path = [],"Float"}, _) -> "Float"
 		| TInst({cl_path = [],"String"},_) -> "String"
-		| TAnon _ | TDynamic _ -> "Dynamic"
+		| TAnon _ | TDynamic -> "Dynamic"
 		| _ -> print_endline (debug_type t); die "" __LOC__
 	in
 	let rcf_static_insert t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) null_pos [] in
@@ -2522,8 +2522,8 @@ let generate con =
 					{ e1 with eexpr = TBinop(Ast.OpEq, e1, e2); etype = basic.tbool }
 				| _ ->
 				let is_ref = match follow e1.etype, follow e2.etype with
-					| TDynamic _, _
-					| _, TDynamic _
+					| TDynamic, _
+					| _, TDynamic
 					| TAbstract ({ a_path = ([], "Float") },[]) , _
 					| TInst( { cl_path = (["haxe"], "Int32") }, [] ), _
 					| TInst( { cl_path = (["haxe"], "Int64") }, [] ), _

+ 1 - 1
src/generators/genjs.ml

@@ -359,7 +359,7 @@ let is_dynamic_iterator ctx e =
 			| TInst ({ cl_path = [],"Array" },_)
 			| TInst ({ cl_kind = KTypeParameter _}, _)
 			| TAnon _
-			| TDynamic _
+			| TDynamic
 			| TMono _ ->
 				true
 			| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->

+ 1 - 1
src/generators/genjvm.ml

@@ -132,7 +132,7 @@ let rec jsignature_of_type gctx stack t =
 				else
 					jsignature_of_type (Abstract.get_underlying_type a tl)
 		end
-	| TDynamic _ -> object_sig
+	| TDynamic -> object_sig
 	| TMono r ->
 		begin match r.tm_type with
 		| Some t -> jsignature_of_type t

+ 2 - 2
src/generators/genlua.ml

@@ -272,7 +272,7 @@ let is_string_expr e = is_string_type e.etype
 (* /from genphp *)
 
 let is_dynamic t = match follow t with
-    | TMono _ | TDynamic _
+    | TMono _ | TDynamic
     | TInst({ cl_kind = KTypeParameter _ }, _) -> true
     | TAnon anon ->
         (match !(anon.a_status) with
@@ -285,7 +285,7 @@ let is_dynamic_expr e = is_dynamic e.etype
 
 let is_structural_type t =
     match follow t with
-    | TDynamic _ -> true
+    | TDynamic -> true
     | TAnon a -> true
     | TType ({t_type = TAnon _},_) -> true
     | _ -> false

+ 1 - 1
src/generators/genneko.ml

@@ -333,7 +333,7 @@ and gen_expr ctx e =
 					| TInst (c,_) -> Some c.cl_path
 					| TEnum (e,_) -> Some e.e_path
 					| TAbstract (a,_) -> Some a.a_path
-					| TDynamic _ -> None
+					| TDynamic -> None
 					| _ -> die "" __LOC__
 				) in
 				let cond = (match path with

+ 2 - 2
src/generators/genphp7.ml

@@ -239,7 +239,7 @@ let fail ?msg p = Globals.die (Option.default "" msg) ~p
 (**
 	Check if `target` is a `Dynamic` type
 *)
-let rec is_dynamic_type (target:Type.t) = match follow target with TDynamic _ -> true | _ -> false
+let rec is_dynamic_type (target:Type.t) = match follow target with TDynamic -> true | _ -> false
 
 (**
 	Check if `target` is `php.Ref`
@@ -1335,7 +1335,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 					)
 				| TFun _ -> self#use ~prefix:false ([], "Closure")
 				| TAnon _ -> "object"
-				| TDynamic _ -> "mixed"
+				| TDynamic -> "mixed"
 				| TLazy _ -> fail ~msg:"TLazy not implemented" self#pos __LOC__
 				| TMono mono ->
 					(match mono.tm_type with

+ 5 - 5
src/generators/genpy.ml

@@ -1047,7 +1047,7 @@ module Printer = struct
 	let rec is_anon_or_dynamic t = match follow t with
 		| TAbstract(a,tl) ->
 			is_anon_or_dynamic (Abstract.get_underlying_type a tl)
-		| TAnon _ | TDynamic _ -> true
+		| TAnon _ | TDynamic -> true
 		| _ -> false
 
 	let handle_keywords s =
@@ -1292,11 +1292,11 @@ module Printer = struct
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
 				| _, TInst({ cl_kind = KTypeParameter(_) }, _) ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
-				| TDynamic _, TDynamic _ ->
+				| TDynamic, TDynamic ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
-				| TDynamic _, x when is_list_or_anon x ->
+				| TDynamic, x when is_list_or_anon x ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
-				| x, TDynamic _ when is_list_or_anon x ->
+				| x, TDynamic when is_list_or_anon x ->
 					Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2)
 				| _,_ -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (snd ops) (print_expr pctx e2))
 			| TBinop(OpMod,e1,e2) when (is_type1 "" "Int")(e1.etype) && (is_type1 "" "Int")(e2.etype) ->
@@ -1332,7 +1332,7 @@ module Printer = struct
 				let e1_str = safe_string e1 in
 				let e2_str = safe_string e2 in
 				Printf.sprintf "(%s + %s)" e1_str e2_str
-			| TBinop(OpAdd,e1,e2) when (match follow e.etype with TDynamic _ -> true | _ -> false) ->
+			| TBinop(OpAdd,e1,e2) when (match follow e.etype with TDynamic -> true | _ -> false) ->
 				Printf.sprintf "python_Boot._add_dynamic(%s,%s)" (print_expr pctx e1) (print_expr pctx e2)
 			| TBinop(op,e1,e2) ->
 				Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (print_binop op) (print_expr pctx e2)

+ 2 - 2
src/generators/genswf.ml

@@ -83,8 +83,8 @@ let build_dependencies t =
 			add_type_rec (t::l) t2;
 		| TAnon a ->
 			PMap.iter (fun _ f -> add_type_rec (t::l) f.cf_type) a.a_fields
-		| TDynamic t2 ->
-			add_type_rec (t::l) t2;
+		| TDynamic ->
+			()
 		| TLazy f ->
 			add_type_rec l (lazy_type f)
 		| TMono r ->

+ 2 - 2
src/generators/genswf9.ml

@@ -247,7 +247,7 @@ let rec type_id ctx t =
 
 let type_opt ctx t =
 	match follow_basic t with
-	| TDynamic _ | TMono _ | TAbstract ({a_path = [],"Void"},_) -> None
+	| TDynamic | TMono _ | TAbstract ({a_path = [],"Void"},_) -> None
 	| _ -> Some (type_id ctx t)
 
 let type_void ctx t =
@@ -285,7 +285,7 @@ let classify ctx t =
 		KType (type_id ctx t)
 	| TMono _
 	| TType _
-	| TDynamic _ ->
+	| TDynamic ->
 		KDynamic
 	| TLazy _ ->
 		die "" __LOC__

+ 1 - 1
src/macro/eval/evalJit.ml

@@ -30,7 +30,7 @@ open EvalMisc
 
 let rope_path t = match follow t with
 	| TInst({cl_path=path},_) | TEnum({e_path=path},_) | TAbstract({a_path=path},_) -> s_type_path path
-	| TDynamic _ -> "Dynamic"
+	| TDynamic -> "Dynamic"
 	| TFun _ | TAnon _ | TMono _ | TType _ | TLazy _ -> die "" __LOC__
 
 let eone = mk (TConst(TInt (Int32.one))) t_dynamic null_pos

+ 1 - 1
src/macro/eval/evalMain.ml

@@ -552,7 +552,7 @@ let handle_decoding_error f v t =
 			end
 		| TLazy r ->
 			loop tabs (lazy_type r) v
-		| TDynamic _ ->
+		| TDynamic ->
 			()
 	in
 	loop "" t v;

+ 4 - 7
src/macro/macroApi.ml

@@ -1075,11 +1075,8 @@ and encode_type t =
 			4 , [encode_array pl; encode_type ret]
 		| TAnon a ->
 			5, [encode_ref a encode_tanon (fun() -> "<anonymous>")]
-		| TDynamic tsub as t ->
-			if t == t_dynamic then
-				6, [vnull]
-			else
-				6, [encode_type tsub]
+		| TDynamic ->
+			6, [vnull]
 		| TLazy f ->
 			loop (lazy_type f)
 		| TAbstract (a, pl) ->
@@ -1123,7 +1120,7 @@ and decode_type t =
 	| 3, [t; pl] -> TType (decode_ref t, List.map decode_type (decode_array pl))
 	| 4, [pl; r] -> TFun (List.map (fun p -> decode_string (field p "name"), decode_bool (field p "opt"), decode_type (field p "t")) (decode_array pl), decode_type r)
 	| 5, [a] -> TAnon (decode_ref a)
-	| 6, [t] -> if t = vnull then t_dynamic else TDynamic (decode_type t)
+	| 6, [t] -> t_dynamic (* DYNAMICTODO *)
 	| 7, [f] -> TLazy (decode_lazytype f)
 	| 8, [a; pl] -> TAbstract (decode_ref a, List.map decode_type (decode_array pl))
 	| _ -> raise Invalid_expr
@@ -1812,7 +1809,7 @@ let macro_api ccom get_api =
 					| Some t -> t)
 				| TAbstract (a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 					Abstract.get_underlying_type a tl
-				| TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic _ ->
+				| TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic ->
 					t
 				| TType (t,tl) ->
 					apply_params t.t_params tl t.t_type

+ 1 - 1
src/optimization/analyzerTexpr.ml

@@ -181,7 +181,7 @@ let type_change_ok com t1 t2 =
 		in
 		(* Check equality again to cover cases where TMono became t_dynamic *)
 		t1 == t2 || match follow t1,follow t2 with
-			| TDynamic _,_ | _,TDynamic _ -> false
+			| TDynamic,_ | _,TDynamic -> false
 			| _ ->
 				if com.config.pf_static && is_nullable_or_whatever t1 <> is_nullable_or_whatever t2 then false
 				else type_iseq t1 t2

+ 6 - 9
src/optimization/dce.ml

@@ -249,7 +249,7 @@ and mark_t dce p t =
 			List.iter (mark_t dce p) pl;
 			if not (Meta.has Meta.CoreType a.a_meta) then
 				mark_t dce p (Abstract.get_underlying_type a pl)
-		| TLazy _ | TDynamic _ | TType _ | TAnon _ | TMono _ -> ()
+		| TLazy _ | TDynamic | TType _ | TAnon _ | TMono _ -> ()
 		end;
 		dce.t_stack <- List.tl dce.t_stack
 	end
@@ -312,11 +312,8 @@ let rec to_string dce t = match t with
 		| _ -> ())
 	| TLazy f ->
 		to_string dce (lazy_type f)
-	| TDynamic t ->
-		if t == t_dynamic then
-			()
-		else
-			to_string dce t
+	| TDynamic ->
+		()
 	| TEnum _ | TFun _ | TAnon _ | TAbstract({a_impl = None},_) ->
 		(* if we to_string these it does not imply that we need all its sub-types *)
 		()
@@ -416,7 +413,7 @@ and is_array t = match follow t with
 
 and is_dynamic t = match follow t with
 	| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> is_dynamic (Abstract.get_underlying_type a tl)
-	| TDynamic _ -> true
+	| TDynamic -> true
 	| _ -> false
 
 and is_string t = match follow t with
@@ -585,11 +582,11 @@ and expr dce e =
 		check_and_add_feature dce "unsafe_string_concat";
 		expr dce e1;
 		expr dce e2;
-	| TArray(({etype = TDynamic t} as e1),e2) when t == t_dynamic ->
+	| TArray(({etype = TDynamic} as e1),e2) ->
 		check_and_add_feature dce "dynamic_array_read";
 		expr dce e1;
 		expr dce e2;
-	| TBinop( (OpAssign | OpAssignOp _), ({eexpr = TArray({etype = TDynamic t},_)} as e1), e2) when t == t_dynamic ->
+	| TBinop( (OpAssign | OpAssignOp _), ({eexpr = TArray({etype = TDynamic},_)} as e1), e2) ->
 		check_and_add_feature dce "dynamic_array_write";
 		expr dce e1;
 		expr dce e2;

+ 1 - 1
src/typing/fields.ml

@@ -403,7 +403,7 @@ let rec type_field cfg ctx e i p mode =
 		with Not_found ->
 			if PMap.mem i c.cl_statics then error ("Cannot access static field " ^ i ^ " from a class instance") pfield;
 			no_field())
-	| TDynamic t ->
+	| TDynamic as t | TAbstract({a_path=([],"Dynamic")},[t]) ->
 		(try
 			using_field ctx mode e i p
 		with Not_found ->

+ 4 - 4
src/typing/forLoop.ml

@@ -88,7 +88,7 @@ module IterationKind = struct
 		let e1 = try
 			let e = AbstractCast.cast_or_unify_raise ctx t e p in
 			match Abstract.follow_with_abstracts e.etype with
-			| TDynamic _ | TMono _ ->
+			| TDynamic | TMono _ ->
 				(* try to find something better than a dynamic value to iterate on *)
 				dynamic_iterator := Some e;
 				raise (Error (Unify [Unify_custom "Avoid iterating on a dynamic value"], p))
@@ -185,7 +185,7 @@ module IterationKind = struct
 			| Some result -> result
 			| None ->
 				match Abstract.follow_with_abstracts e1.etype with
-					| (TMono _ | TDynamic _) -> dynamic_iterator e1;
+					| (TMono _ | TDynamic) -> dynamic_iterator e1;
 					| _ -> (IteratorIterator,e1,pt)
 		in
 		let try_forward_array_iterator () =
@@ -251,7 +251,7 @@ module IterationKind = struct
 			with Not_found -> check_iterator ())
 		| _,TInst ({ cl_kind = KGenericInstance ({ cl_path = ["haxe";"ds"],"GenericStack" },[pt]) } as c,[]) ->
 			IteratorGenericStack c,e,pt
-		| _,(TMono _ | TDynamic _) ->
+		| _,(TMono _ | TDynamic) ->
 			dynamic_iterator e
 		| _ ->
 			check_iterator ()
@@ -501,7 +501,7 @@ let type_for_loop ctx handle_display it e2 p =
 		end
 	| IKKeyValue((ikey,pkey,dkokey),(ivalue,pvalue,dkovalue)) ->
 		(match follow e1.etype with
-		| TDynamic _ | TMono _ ->
+		| TDynamic | TMono _ ->
 			display_error ctx "You can't iterate on a Dynamic value, please specify KeyValueIterator or KeyValueIterable" e1.epos;
 		| _ -> ()
 		);

+ 3 - 3
src/typing/generic.ml

@@ -50,7 +50,7 @@ let make_generic ctx ps pt p =
 				| _ when not top ->
 					follow_or t top (fun() -> "_") (* allow unknown/incompatible types as type parameters to retain old behavior *)
 				| TMono { tm_type = None } -> raise (Generic_Exception (("Could not determine type for parameter " ^ s), p))
-				| TDynamic _ -> "Dynamic"
+				| TDynamic -> "Dynamic"
 				| t ->
 					follow_or t top (fun() -> raise (Generic_Exception (("Unsupported type parameter: " ^ (s_type (print_context()) t) ^ ")"), p)))
 			and loop_tl top tl = match tl with
@@ -231,8 +231,8 @@ let rec build_generic ctx c p tl =
 				| Some t -> loop t)
 			| TLazy f ->
 				loop (lazy_type f);
-			| TDynamic t2 ->
-				if t == t2 then () else loop t2
+			| TDynamic ->
+				()
 			| TAnon a ->
 				PMap.iter (fun _ f -> loop f.cf_type) a.a_fields
 			| TFun (args,ret) ->

+ 2 - 2
src/typing/matcher.ml

@@ -394,7 +394,7 @@ module Pattern = struct
 						in
 						let patterns = loop el tl in
 						PatTuple patterns
-					| TInst({cl_path=[],"Array"},[t2]) | (TDynamic _ as t2) ->
+					| TInst({cl_path=[],"Array"},[t2]) | (TDynamic as t2) ->
 						let patterns = ExtList.List.mapi (fun i e ->
 							make pctx false t2 e
 						) el in
@@ -1367,7 +1367,7 @@ module TexprConverter = struct
 				e,t,true
 		in
 		let e,t,inferred = match follow e.etype with
-			| TDynamic _ | TMono _ ->
+			| TDynamic | TMono _ ->
 				infer_type()
 			| _ ->
 				e,e.etype,false

+ 1 - 1
src/typing/nullSafety.ml

@@ -370,7 +370,7 @@ let rec can_pass_type src dst =
 			| TType (t, tl) -> can_pass_type src (apply_params t.t_params tl t.t_type)
 			| TFun _ -> true
 			| TAnon _ -> true
-			| TDynamic _ -> true
+			| TDynamic -> true
 			| TLazy _ -> true
 			| TAbstract ({ a_path = ([],"Null") }, [t]) -> true
 			| TAbstract _ -> true

+ 2 - 5
src/typing/typeload.ml

@@ -332,11 +332,8 @@ let rec load_instance' ctx (t,p) allow_no_params =
 		if allow_no_params && t.tparams = [] && not is_rest then begin
 			let monos = Monomorph.spawn_constrained_monos (fun t -> t) types in
 			f (monos)
-		end else if path = ([],"Dynamic") then
-			match t.tparams with
-			| [] -> t_dynamic
-			| [TPType t] -> TDynamic (load_complex_type ctx true t)
-			| _ -> error "Too many parameters for Dynamic" p
+		end else if path = ([],"Dynamic") && t.tparams = [] then
+			t_dynamic
 		else begin
 			let is_java_rest = ctx.com.platform = Java && is_extern in
 			let is_rest = is_rest || is_java_rest in

+ 1 - 1
src/typing/typeloadCheck.ml

@@ -487,7 +487,7 @@ module Inheritance = struct
 						check_cancel_build intf;
 						process_meta intf;
 					)
-				| TDynamic t ->
+				| TDynamic as t ->
 					if c.cl_dynamic <> None then error "Cannot have several dynamics" p;
 					if not c.cl_extern then display_error ctx "In haxe 4, implements Dynamic is only supported on externs" p;
 					c.cl_dynamic <- Some t;

+ 1 - 1
src/typing/typeloadFields.ml

@@ -676,7 +676,7 @@ let bind_type (ctx,cctx,fctx) cf r p =
 		match t with
 		| TFun (args,ret) -> is_full_type ret && List.for_all (fun (_,_,t) -> is_full_type t) args
 		| TMono r -> (match r.tm_type with None -> false | Some t -> is_full_type t)
-		| TAbstract _ | TInst _ | TEnum _ | TLazy _ | TDynamic _ | TAnon _ | TType _ -> true
+		| TAbstract _ | TInst _ | TEnum _ | TLazy _ | TDynamic | TAnon _ | TType _ -> true
 	in
 	let force_macro () =
 		(* force macro system loading of this class in order to get completion *)

+ 7 - 7
src/typing/typer.ml

@@ -67,7 +67,7 @@ let rec classify t =
 	| TAbstract (a,[]) when List.exists (fun t -> match classify t with KString -> true | _ -> false) a.a_to -> KStrParam t
 	| TInst ({ cl_kind = KTypeParameter ctl },_) when List.exists (fun t -> match classify t with KString -> true | _ -> false) ctl -> KStrParam t
 	| TMono r when r.tm_type = None -> KUnk
-	| TDynamic _ -> KDyn
+	| TDynamic -> KDyn
 	| _ -> KOther
 
 let get_iterator_param t =
@@ -443,7 +443,7 @@ let rec type_ident_raise ctx i p mode =
 let unify_int ctx e k =
 	let is_dynamic t =
 		match follow t with
-		| TDynamic _ -> true
+		| TDynamic -> true
 		| _ -> false
 	in
 	let is_dynamic_array t =
@@ -486,7 +486,7 @@ let unify_int ctx e k =
 		| _ -> false
 	and maybe_dynamic_rec e t =
 		match follow t with
-		| TMono _ | TDynamic _ -> maybe_dynamic_mono e
+		| TMono _ | TDynamic -> maybe_dynamic_mono e
 		(* we might have inferenced a tmono into a single field *)
 		(* TODO: check what this did exactly *)
 		(* | TAnon a when !(a.a_status) = Opened -> maybe_dynamic_mono e *)
@@ -1622,7 +1622,7 @@ and type_object_decl ctx fl with_type p =
 				(match List.fold_left fold [] froms with
 				| [t] -> t
 				| _ -> ODKPlain)
-			| TDynamic t when (follow t != t_dynamic) ->
+			| TAbstract({a_path=([],"Dynamic")},[t]) ->
 				dynamic_parameter := Some t;
 				ODKWithStructure {
 					a_status = ref Closed;
@@ -1877,12 +1877,12 @@ and type_try ctx e1 catches with_type p =
 			in
 			begin try
 				begin match follow t,follow v.v_type with
-					| _, TDynamic _
+					| _, TDynamic
 					| _, TInst({ cl_path = ["haxe"],"Error"},_) ->
 						unreachable()
 					| _, TInst({ cl_path = path },_) when path = ctx.com.config.pf_exceptions.ec_wildcard_catch ->
 						unreachable()
-					| TDynamic _,_ ->
+					| TDynamic,_ ->
 						()
 					| _ ->
 						Type.unify t v.v_type;
@@ -1913,7 +1913,7 @@ and type_try ctx e1 catches with_type p =
 				t
 			| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 				loop (Abstract.get_underlying_type a tl)
-			| TDynamic _ -> t
+			| TDynamic -> t
 			| _ -> error "Catch type must be a class, an enum or Dynamic" (pos e_ast)
 		in
 		let t2 = loop t in

+ 1 - 1
src/typing/typerDisplay.ml

@@ -430,7 +430,7 @@ and display_expr ctx e_ast e dk with_type p =
 		let iterator = try
 			let it = (ForLoop.IterationKind.of_texpr ~resume:true ctx e (fun _ -> false) e.epos) in
 			match follow it.it_type with
-				| TDynamic _ ->  None
+				| TDynamic ->  None
 				| t -> Some t
 			with Error _ | Not_found ->
 				None