|
@@ -1078,13 +1078,13 @@ let init_class ctx c p herits fields =
|
|
if inline && dynamic then error "You can't have both 'inline' and 'dynamic'" p;
|
|
if inline && dynamic then error "You can't have both 'inline' and 'dynamic'" p;
|
|
ctx.curmethod <- name;
|
|
ctx.curmethod <- name;
|
|
ctx.type_params <- if stat then params else params @ ctx.type_params;
|
|
ctx.type_params <- if stat then params else params @ ctx.type_params;
|
|
- let ret = type_opt ctx p fd.f_type in
|
|
|
|
|
|
+ let constr = (name = "new") in
|
|
|
|
+ let ret = if constr then ctx.t.tvoid else type_opt ctx p fd.f_type in
|
|
let args = List.map (fun (name,opt,t,c) ->
|
|
let args = List.map (fun (name,opt,t,c) ->
|
|
let t, c = type_function_param ctx (type_opt ctx p t) c opt p in
|
|
let t, c = type_function_param ctx (type_opt ctx p t) c opt p in
|
|
name, c, t
|
|
name, c, t
|
|
) fd.f_args in
|
|
) fd.f_args in
|
|
let t = TFun (fun_args args,ret) in
|
|
let t = TFun (fun_args args,ret) in
|
|
- let constr = (name = "new") in
|
|
|
|
if constr && c.cl_interface then error "An interface cannot have a constructor" p;
|
|
if constr && c.cl_interface then error "An interface cannot have a constructor" p;
|
|
if c.cl_interface && not stat && fd.f_expr <> None then error "An interface method cannot have a body" p;
|
|
if c.cl_interface && not stat && fd.f_expr <> None then error "An interface method cannot have a body" p;
|
|
if constr then (match fd.f_type with
|
|
if constr then (match fd.f_type with
|