@@ -303,9 +303,9 @@ let rec load_params ctx info params p =
303
303
let is_rest = info.build_kind = BuildGenericBuild && (match info.build_params with [{ttp_name= " Rest" }] -> true | _ -> false ) in
304
304
let is_java_rest = ctx.com.platform = Jvm && info.build_extern in
305
305
let is_rest = is_rest || is_java_rest in
306
- let load_param t =
307
- match t with
308
- | TPExpr e ->
306
+ let load_param t def =
307
+ match (t, def) with
308
+ | TPExpr e , _ ->
309
309
let name = (match fst e with
310
310
| EConst (String(s ,_ )) -> " S" ^ s
311
311
| EConst (Int (_ ,_ ) as c ) -> " I" ^ s_constant c
@@ -318,14 +318,18 @@ let rec load_params ctx info params p =
318
318
let c = mk_class ctx.m.curmod ([] ,name) p (pos e) in
319
319
c.cl_kind < - KExpr e;
320
320
TInst (c,[] ),pos e
321
- | TPType t ->
321
+ | TPType (CTPath({ path = { tpackage = [" $" ]; tname = "_hx_default" } } ),p ), None ->
322
+ raise_typing_error " Cannot apply default type parameter on non-default type parameter" p
323
+ | TPType (CTPath({ path = { tpackage = [" $" ]; tname = "_hx_default" } } ),p ), Some def ->
324
+ def,p
325
+ | TPType t , _ ->
322
326
load_complex_type ctx true LoadNormal t,pos t
323
327
in
324
328
let checks = DynArray. create () in
325
329
let rec loop tl1 tl2 is_rest = match tl1,tl2 with
326
330
| t :: tl1 ,ttp :: tl2 ->
327
331
let name = ttp.ttp_name in
328
- let t,pt = load_param t in
332
+ let t,pt = load_param t ttp.ttp_default in
329
333
let check_const c =
330
334
let is_expression = (match t with TInst ({ cl_kind = KExpr _ } ,_ ) -> true | _ -> false ) in
331
335
let expects_expression = name = " Const" || Meta. has Meta. Const c.cl_meta in
@@ -364,7 +368,7 @@ let rec load_params ctx info params p =
364
368
t :: loop [] tl is_rest
365
369
end
366
370
| t :: tl ,[] ->
367
- let t,pt = load_param t in
371
+ let t,pt = load_param t None in
368
372
if is_rest then
369
373
t :: loop tl [] true
370
374
else if ignore_error ctx.com then
@@ -443,6 +447,7 @@ and load_complex_type' ctx allow_display mode (t,p) =
443
447
match t with
444
448
| CTParent t -> load_complex_type ctx allow_display mode t
445
449
| CTPath { path = {tpackage = [" $" ]; tname = "_hx_mono" } } -> spawn_monomorph ctx p
450
+ | CTPath { path = {tpackage = [" $" ]; tname = "_hx_default" } } -> raise_typing_error " Invalid type : default" p
446
451
| CTPath ptp -> load_instance ~allow_display ctx ptp ParamNormal mode
447
452
| CTOptional _ -> raise_typing_error " Optional type not allowed here" p
448
453
| CTNamed _ -> raise_typing_error " Named type not allowed here" p
0 commit comments