Skip to content

Commit 397b3a0

Browse files
committed
add a_constructor
1 parent 3ab8273 commit 397b3a0

9 files changed

+21
-12
lines changed

src/core/abstract.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ let rec follow_with_forward_ctor ?(build=false) t = match follow t with
155155
| TAbstract(a,tl) as t ->
156156
if build then build_abstract a;
157157
if Meta.has Meta.ForwardNew a.a_meta && not (match a.a_impl with
158-
| Some c -> PMap.mem "_hx_new" c.cl_statics
158+
| Some c -> a.a_constructor <> None
159159
| None -> false
160160
) then
161161
follow_with_forward_ctor (get_underlying_type ~return_first:true a tl)

src/core/display/completionItem.ml

+5-8
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,11 @@ module CompletionModuleType = struct
182182
raise Exit
183183

184184
let of_module_type mt =
185-
let actor a = match a.a_impl with
186-
| None -> No
187-
| Some c ->
188-
try
189-
let cf = PMap.find "_hx_new" c.cl_statics in
190-
if (has_class_flag c CExtern) || (has_class_field_flag cf CfPublic) then Yes else YesButPrivate
191-
with Not_found ->
192-
No
185+
let actor a = match a.a_impl,a.a_constructor with
186+
| Some c,Some cf ->
187+
if (has_class_flag c CExtern) || (has_class_field_flag cf CfPublic) then Yes else YesButPrivate
188+
| _ ->
189+
No
193190
in
194191
let ctor c =
195192
try

src/core/tFunctions.ml

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ let null_abstract = {
299299
a_read = None;
300300
a_write = None;
301301
a_call = None;
302+
a_constructor = None;
302303
a_extern = false;
303304
a_enum = false;
304305
}

src/core/tOther.ml

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ let mk_abstract m path pos name_pos =
300300
a_this = mk_mono();
301301
a_read = None;
302302
a_write = None;
303+
a_constructor = None;
303304
a_extern = false;
304305
a_enum = false;
305306
a_call = None;

src/core/tType.ml

+1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ and tabstract = {
382382
mutable a_read : tclass_field option;
383383
mutable a_write : tclass_field option;
384384
mutable a_call : tclass_field option;
385+
mutable a_constructor : tclass_field option;
385386
mutable a_extern : bool;
386387
mutable a_enum : bool;
387388
}

src/typing/fieldAccess.ml

+9-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,15 @@ let get_constructor_access c tl p =
163163
| _ -> c, tl
164164
in
165165
let cf, fh = match c.cl_kind with
166-
| KAbstractImpl a -> PMap.find "_hx_new" c.cl_statics, FHAbstract(a,tl,c)
167-
| _ -> Type.get_constructor c, FHInstance(c,tl)
166+
| KAbstractImpl a ->
167+
begin match a.a_constructor with
168+
| None ->
169+
raise Not_found
170+
| Some cf ->
171+
cf,FHAbstract(a,tl,c)
172+
end
173+
| _ ->
174+
Type.get_constructor c, FHInstance(c,tl)
168175
in
169176
create e_static cf fh false p
170177
with Not_found ->

src/typing/typeloadFields.ml

+1
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ let create_variable (ctx,cctx,fctx) c f cf t eo p =
929929
cf
930930

931931
let check_abstract (ctx,cctx,fctx) a c cf fd t ret p =
932+
if fctx.is_abstract_constructor then a.a_constructor <- Some cf;
932933
let m = mk_mono() in
933934
let ta = TAbstract(a,List.map (fun _ -> mk_mono()) a.a_params) in
934935
let tthis = if fctx.is_abstract_member || Meta.has Meta.To cf.cf_meta then monomorphs a.a_params a.a_this else a.a_this in

src/typing/typeloadModule.ml

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ module ModuleLevel = struct
197197
a_read = None;
198198
a_write = None;
199199
a_call = None;
200+
a_constructor = None;
200201
a_extern = List.mem AbExtern d.d_flags;
201202
a_enum = List.mem AbEnum d.d_flags || p_enum_meta <> None;
202203
} in

src/typing/typerDisplay.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ let handle_display ctx e_ast dk mode with_type =
619619
| TClassDecl c -> has_constructor c
620620
| TAbstractDecl a -> (match Abstract.follow_with_forward_ctor ~build:true (TAbstract(a,extract_param_types a.a_params)) with
621621
| TInst(c,_) -> has_constructor c
622-
| TAbstract({a_impl = Some c},_) -> PMap.mem "_hx_new" c.cl_statics
622+
| TAbstract(a,_) -> a.a_constructor <> None
623623
| _ -> false)
624624
| _ -> false
625625
end

0 commit comments

Comments
 (0)