Преглед на файлове

[cs] try to get the wonky cast code right

Simon Krajewski преди 5 години
родител
ревизия
ee3d4629b9
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      src/codegen/gencommon/realTypeParams.ml

+ 4 - 3
src/codegen/gencommon/realTypeParams.ml

@@ -400,7 +400,7 @@ struct
 		let this = { eexpr = TConst TThis; etype = (TInst(cl, List.map snd cl.cl_params)); epos = p } in
 
 		let rec loop curcls params level reverse_params =
-			if (level <> 0 || (has_class_flag curcls CInterface)) && params <> [] && is_hxgeneric (TClassDecl curcls) then begin
+			if (level <> 0 || (has_class_flag curcls CInterface) || (has_class_flag curcls CAbstract) ) && params <> [] && is_hxgeneric (TClassDecl curcls) then begin
 				let cparams = List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) curcls.cl_params in
 				let name = get_cast_name curcls in
 				if not (PMap.mem name cl.cl_fields) then begin
@@ -695,7 +695,7 @@ struct
 					in
 					loop cl;
 
-					(if not (has_class_flag cl CInterface) then cl.cl_ordered_fields <- cast_cf :: cl.cl_ordered_fields);
+					(if not (has_class_flag cl CInterface) && not (has_class_flag cl CAbstract) then cl.cl_ordered_fields <- cast_cf :: cl.cl_ordered_fields);
 					let iface_cf = mk_class_field name cast_cf.cf_type false cast_cf.cf_pos (Method MethNormal) cast_cf.cf_params in
 					let cast_static_cf, delay = create_static_cast_cf gen iface iface_cf in
 
@@ -707,6 +707,7 @@ struct
 					iface.cl_fields <- PMap.add name iface_cf iface.cl_fields;
 					let fields = List.filter (fun cf -> match cf.cf_kind with
 						| Var _ | Method MethDynamic -> false
+						| Method _ when has_class_field_flag cf CfAbstract -> false
 						| _ ->
 							let is_override = has_class_field_flag cf CfOverride in
 							let cf_type = if is_override && not (Meta.has Meta.Overload cf.cf_meta) then
@@ -721,7 +722,7 @@ struct
 						) cl.cl_ordered_fields
 					in
 					let fields = List.map (fun f -> mk_class_field f.cf_name f.cf_type (has_class_field_flag f CfPublic) f.cf_pos f.cf_kind f.cf_params) fields in
-					let fields = iface_cf :: fields in
+					let fields = if has_class_flag cl CAbstract then fields else iface_cf :: fields in
 					iface.cl_ordered_fields <- fields;
 					List.iter (fun f -> iface.cl_fields <- PMap.add f.cf_name f iface.cl_fields) fields;