@@ -54,6 +54,7 @@ type field_init_ctx = {
54
54
is_abstract : bool ;
55
55
is_macro : bool ;
56
56
is_abstract_member : bool ;
57
+ is_abstract_constructor : bool ;
57
58
is_display_field : bool ;
58
59
is_field_debug : bool ;
59
60
is_generic : bool ;
@@ -529,6 +530,7 @@ let create_field_context ctx cctx cff is_display_file display_modifier =
529
530
is_field_debug = cctx.is_class_debug || Meta. has (Meta. Custom " :debug.typeload" ) cff.cff_meta;
530
531
display_modifier = display_modifier;
531
532
is_abstract_member = is_abstract_member;
533
+ is_abstract_constructor = is_abstract_member && fst cff.cff_name = " _hx_new" ;
532
534
is_generic = Meta. has Meta. Generic cff.cff_meta;
533
535
field_kind = field_kind;
534
536
do_bind = (((not ((has_class_flag c CExtern ) || ! is_extern) || is_inline) && not is_abstract && not (has_class_flag c CInterface )) || field_kind = CfrInit );
@@ -631,7 +633,7 @@ let check_field_display ctx fctx c cf =
631
633
let scope, cf = match c.cl_kind with
632
634
| KAbstractImpl _ ->
633
635
if has_class_field_flag cf CfImpl then
634
- (if cf.cf_name = " _hx_new " then
636
+ (if fctx.is_abstract_constructor then
635
637
CFSConstructor , {cf with cf_name = " new" }
636
638
else
637
639
CFSMember , cf)
@@ -1087,7 +1089,7 @@ let check_abstract (ctx,cctx,fctx) a c cf fd t ret p =
1087
1089
| _ -> () ;
1088
1090
in
1089
1091
List. iter check_meta cf.cf_meta;
1090
- if cf.cf_name = " _hx_new " && Meta. has Meta. MultiType a.a_meta then fctx.do_bind < - false ;
1092
+ if fctx.is_abstract_constructor && Meta. has Meta. MultiType a.a_meta then fctx.do_bind < - false ;
1091
1093
if fd.f_expr = None then begin
1092
1094
if fctx.is_inline then missing_expression ctx.com fctx " Inline functions must have an expression" cf.cf_pos;
1093
1095
if fd.f_type = None then raise_typing_error (" Functions without expressions must have an explicit return type" ) cf.cf_pos;
@@ -1160,7 +1162,7 @@ let setup_args_ret ctx cctx fctx name fd p =
1160
1162
maybe_use_property_type fd.f_type (fun () -> match Lazy. force mk with MKGetter | MKSetter -> true | _ -> false ) def
1161
1163
end in
1162
1164
let abstract_this = match cctx.abstract with
1163
- | Some a when fctx.is_abstract_member && name <> " _hx_new " (* TODO: this sucks *) && not fctx.is_macro ->
1165
+ | Some a when fctx.is_abstract_member && not fctx.is_abstract_constructor && not fctx.is_macro ->
1164
1166
Some a.a_this
1165
1167
| _ ->
1166
1168
None
@@ -1271,6 +1273,7 @@ let create_method (ctx,cctx,fctx) c f cf fd p =
1271
1273
add_class_field_flag cf CfAbstract ;
1272
1274
end ;
1273
1275
if fctx.is_abstract_member then add_class_field_flag cf CfImpl ;
1276
+ if fctx.is_abstract_constructor then add_class_field_flag cf CfAbstractConstructor ;
1274
1277
if fctx.is_generic then add_class_field_flag cf CfGeneric ;
1275
1278
begin match fctx.default with
1276
1279
| Some p ->
0 commit comments