|
18 | 18 | (* Typechecking of type expressions for the core language *)
|
19 | 19 |
|
20 | 20 | open Asttypes
|
21 |
| -open Misc |
22 | 21 | open Parsetree
|
23 | 22 | open Typedtree
|
24 | 23 | open Types
|
@@ -388,86 +387,7 @@ and transl_type_aux env policy styp =
|
388 | 387 | | Ptyp_object (fields, o) ->
|
389 | 388 | let ty, fields = transl_fields env policy o fields in
|
390 | 389 | ctyp (Ttyp_object (fields, o)) (newobj ty)
|
391 |
| - | Ptyp_class(lid, stl) -> |
392 |
| - let (path, decl, _is_variant) = |
393 |
| - try |
394 |
| - let path = Env.lookup_type lid.txt env in |
395 |
| - let decl = Env.find_type path env in |
396 |
| - let rec check decl = |
397 |
| - match decl.type_manifest with |
398 |
| - None -> raise Not_found |
399 |
| - | Some ty -> |
400 |
| - match (repr ty).desc with |
401 |
| - Tvariant row when Btype.static_row row -> () |
402 |
| - | Tconstr (path, _, _) -> |
403 |
| - check (Env.find_type path env) |
404 |
| - | _ -> raise Not_found |
405 |
| - in check decl; |
406 |
| - Location.deprecated styp.ptyp_loc |
407 |
| - "old syntax for polymorphic variant type"; |
408 |
| - (path, decl,true) |
409 |
| - with Not_found -> try |
410 |
| - let lid2 = |
411 |
| - match lid.txt with |
412 |
| - Longident.Lident s -> Longident.Lident ("#" ^ s) |
413 |
| - | Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s) |
414 |
| - | Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type" |
415 |
| - in |
416 |
| - let path = Env.lookup_type lid2 env in |
417 |
| - let decl = Env.find_type path env in |
418 |
| - (path, decl, false) |
419 |
| - with Not_found -> |
420 |
| - ignore (find_class env lid.loc lid.txt); assert false |
421 |
| - in |
422 |
| - if List.length stl <> decl.type_arity then |
423 |
| - raise(Error(styp.ptyp_loc, env, |
424 |
| - Type_arity_mismatch(lid.txt, decl.type_arity, |
425 |
| - List.length stl))); |
426 |
| - let args = List.map (transl_type env policy) stl in |
427 |
| - let params = instance_list decl.type_params in |
428 |
| - List.iter2 |
429 |
| - (fun (sty, cty) ty' -> |
430 |
| - try unify_var env ty' cty.ctyp_type with Unify trace -> |
431 |
| - raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) |
432 |
| - (List.combine stl args) params; |
433 |
| - let ty_args = List.map (fun ctyp -> ctyp.ctyp_type) args in |
434 |
| - let ty = |
435 |
| - try Ctype.expand_head env (newconstr path ty_args) |
436 |
| - with Unify trace -> |
437 |
| - raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) |
438 |
| - in |
439 |
| - let ty = match ty.desc with |
440 |
| - Tvariant row -> |
441 |
| - let row = Btype.row_repr row in |
442 |
| - let fields = |
443 |
| - List.map |
444 |
| - (fun (l,f) -> l, |
445 |
| - match Btype.row_field_repr f with |
446 |
| - | Rpresent (Some ty) -> |
447 |
| - Reither(false, [ty], false, ref None) |
448 |
| - | Rpresent None -> |
449 |
| - Reither (true, [], false, ref None) |
450 |
| - | _ -> f) |
451 |
| - row.row_fields |
452 |
| - in |
453 |
| - let row = { row_closed = true; row_fields = fields; |
454 |
| - row_bound = (); row_name = Some (path, ty_args); |
455 |
| - row_fixed = false; row_more = newvar () } in |
456 |
| - let static = Btype.static_row row in |
457 |
| - let row = |
458 |
| - if static then { row with row_more = newty Tnil } |
459 |
| - else if policy <> Univars then row |
460 |
| - else { row with row_more = new_pre_univar () } |
461 |
| - in |
462 |
| - newty (Tvariant row) |
463 |
| - | Tobject (fi, _) -> |
464 |
| - let _, tv = flatten_fields fi in |
465 |
| - if policy = Univars then pre_univars := tv :: !pre_univars; |
466 |
| - ty |
467 |
| - | _ -> |
468 |
| - assert false |
469 |
| - in |
470 |
| - ctyp (Ttyp_class (path, lid, args)) ty |
| 390 | + | Ptyp_class() -> assert false |
471 | 391 | | Ptyp_alias(st, alias) ->
|
472 | 392 | let cty =
|
473 | 393 | try
|
|
0 commit comments