Bladeren bron

try something

Dan Korostelev 4 jaren geleden
bovenliggende
commit
15b23565de
2 gewijzigde bestanden met toevoegingen van 14 en 2 verwijderingen
  1. 10 1
      src/filters/filters.ml
  2. 4 1
      src/typing/typeloadFunction.ml

+ 10 - 1
src/filters/filters.ml

@@ -502,7 +502,16 @@ let add_field_inits locals ctx t =
 				match cf.cf_expr with
 				match cf.cf_expr with
 				| Some { eexpr = TFunction f } ->
 				| Some { eexpr = TFunction f } ->
 					let bl = match f.tf_expr with {eexpr = TBlock b } -> b | x -> [x] in
 					let bl = match f.tf_expr with {eexpr = TBlock b } -> b | x -> [x] in
-					let ce = mk (TFunction {f with tf_expr = mk (TBlock (el @ bl)) ctx.com.basic.tvoid c.cl_pos }) cf.cf_type cf.cf_pos in
+					let bl =
+						if (not ctx.com.config.pf_this_before_super
+							&& Meta.has (Meta.Custom ":passThroughCtor") cf.cf_meta
+							&& Meta.has (Meta.Custom ":safe") cf.cf_meta
+						) then
+							bl @ el
+						else
+							el @ bl
+					in
+					let ce = mk (TFunction {f with tf_expr = mk (TBlock bl) ctx.com.basic.tvoid c.cl_pos }) cf.cf_type cf.cf_pos in
 					{cf with cf_expr = Some ce };
 					{cf with cf_expr = Some ce };
 				| _ ->
 				| _ ->
 					die "" __LOC__
 					die "" __LOC__

+ 4 - 1
src/typing/typeloadFunction.ml

@@ -186,10 +186,13 @@ let add_constructor ctx c force_constructor p =
 	let constructor = try Some (Type.get_constructor_class c (List.map snd c.cl_params)) with Not_found -> None in
 	let constructor = try Some (Type.get_constructor_class c (List.map snd c.cl_params)) with Not_found -> None in
 	match constructor with
 	match constructor with
 	| Some(cfsup,csup,cparams) when not (has_class_flag c CExtern) ->
 	| Some(cfsup,csup,cparams) when not (has_class_flag c CExtern) ->
+		let filter_meta (m,_,_) =
+			m = Meta.CompilerGenerated || m = Meta.Custom ":safe"
+		in
 		let cf = {
 		let cf = {
 			cfsup with
 			cfsup with
 			cf_pos = p;
 			cf_pos = p;
-			cf_meta = List.filter (fun (m,_,_) -> m = Meta.CompilerGenerated) cfsup.cf_meta;
+			cf_meta = (Meta.Custom ":passThroughCtor",[],null_pos) :: (List.filter filter_meta cfsup.cf_meta);
 			cf_doc = None;
 			cf_doc = None;
 			cf_expr = None;
 			cf_expr = None;
 		} in
 		} in