@@ -303,7 +303,7 @@ 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 def =
306
+ let load_param t ttp =
307
307
match t with
308
308
| TPExpr e ->
309
309
let name = (match fst e with
@@ -319,9 +319,14 @@ let rec load_params ctx info params p =
319
319
c.cl_kind < - KExpr e;
320
320
TInst (c,[] ),pos e
321
321
| TPType (CTPath({ path = { tpackage = [" $" ]; tname = "_hx_default" } } ),p ) ->
322
- (match def with
323
- | Some def -> def,p
324
- | None -> raise_typing_error " Cannot apply default type parameter on non-default type parameter" p
322
+ (match ttp with
323
+ | Some { ttp_default = Some def } -> def,p
324
+ | Some ttp ->
325
+ raise_typing_error (Printf. sprintf " Invalid default, type parameter %s has no default value" ttp.ttp_name) p
326
+ | None when is_rest ->
327
+ raise_typing_error " Cannot use default with rest type parameters" p
328
+ | None ->
329
+ raise_typing_error (" Too many type parameters for " ^ s_type_path info.build_path) p
325
330
)
326
331
| TPType t ->
327
332
load_complex_type ctx true LoadNormal t,pos t
@@ -330,7 +335,7 @@ let rec load_params ctx info params p =
330
335
let rec loop tl1 tl2 is_rest = match tl1,tl2 with
331
336
| t :: tl1 ,ttp :: tl2 ->
332
337
let name = ttp.ttp_name in
333
- let t,pt = load_param t ttp.ttp_default in
338
+ let t,pt = load_param t ( Some ttp) in
334
339
let check_const c =
335
340
let is_expression = (match t with TInst ({ cl_kind = KExpr _ } ,_ ) -> true | _ -> false ) in
336
341
let expects_expression = name = " Const" || Meta. has Meta. Const c.cl_meta in
0 commit comments