@@ -2323,13 +2323,21 @@ end
|
2323 | 2323 | and UnionRep : sig
|
2324 | 2324 | type t
|
2325 | 2325 |
|
| 2326 | +type union_kind = |
| 2327 | +| ProvidersKind |
| 2328 | +| ConditionalKind |
| 2329 | +| ImplicitInstiationKind |
| 2330 | +| ResolvedKind |
| 2331 | +| LogicalKind |
| 2332 | +| UnknownKind |
| 2333 | + |
2326 | 2334 | val same_source : t -> t -> bool
|
2327 | 2335 |
|
2328 | 2336 | val same_structure : t -> t -> bool
|
2329 | 2337 |
|
2330 | 2338 | (** build a rep from list of members *)
|
2331 | 2339 | val make :
|
2332 |
| -?source_aloc:ALoc.id -> ?synthetic:bool -> TypeTerm.t -> TypeTerm.t -> TypeTerm.t list -> t |
| 2340 | +?source_aloc:ALoc.id -> ?kind:union_kind -> TypeTerm.t -> TypeTerm.t -> TypeTerm.t list -> t |
2333 | 2341 |
|
2334 | 2342 | (** members in declaration order *)
|
2335 | 2343 | val members : t -> TypeTerm.t list
|
@@ -2342,6 +2350,8 @@ and UnionRep : sig
|
2342 | 2350 |
|
2343 | 2351 | val is_synthetic : t -> bool
|
2344 | 2352 |
|
| 2353 | +val union_kind : t -> union_kind |
| 2354 | + |
2345 | 2355 | (** map rep r to rep r' along type mapping f. if nothing would be changed,
|
2346 | 2356 | returns the physically-identical rep. *)
|
2347 | 2357 | val ident_map : ?always_keep_source:bool -> (TypeTerm.t -> TypeTerm.t) -> t -> t
|
@@ -2475,6 +2485,14 @@ end = struct
|
2475 | 2485 | | NoCandidateMembers
|
2476 | 2486 | | NoCommonKeys
|
2477 | 2487 |
|
| 2488 | +type union_kind = |
| 2489 | +| ProvidersKind |
| 2490 | +| ConditionalKind |
| 2491 | +| ImplicitInstiationKind |
| 2492 | +| ResolvedKind |
| 2493 | +| LogicalKind |
| 2494 | +| UnknownKind |
| 2495 | + |
2478 | 2496 | type t = {
|
2479 | 2497 | t0: TypeTerm.t;
|
2480 | 2498 | t1: TypeTerm.t;
|
@@ -2488,7 +2506,7 @@ end = struct
|
2488 | 2506 | (* A union is synthetic roughly when it does not emerge from an annotation,
|
2489 | 2507 | * e.g. when it emerges as the collection of lower bounds during implicit
|
2490 | 2508 | * instantiation. *)
|
2491 |
| -synthetic: bool; |
| 2509 | +kind: union_kind; |
2492 | 2510 | }
|
2493 | 2511 |
|
2494 | 2512 | let same_source { source_aloc = s1; _ } { source_aloc = s2; _ } =
|
@@ -2524,7 +2542,12 @@ end = struct
|
2524 | 2542 | | DefT (_, NullT) -> Some NullTag
|
2525 | 2543 | | _ -> None
|
2526 | 2544 |
|
2527 |
| -let is_synthetic { synthetic; _ } = synthetic |
| 2545 | +let is_synthetic { kind; _ } = |
| 2546 | +match kind with |
| 2547 | +| UnknownKind -> false |
| 2548 | +| _ -> true |
| 2549 | + |
| 2550 | +let union_kind { kind; _ } = kind |
2528 | 2551 |
|
2529 | 2552 | (** given a list of members, build a rep.
|
2530 | 2553 | specialized reps are used on compatible type lists *)
|
@@ -2539,14 +2562,14 @@ end = struct
|
2539 | 2562 | | _ -> None
|
2540 | 2563 | end
|
2541 | 2564 | in
|
2542 |
| -fun ?source_aloc ?(synthetic = false) t0 t1 ts -> |
| 2565 | +fun ?source_aloc ?(kind = UnknownKind) t0 t1 ts -> |
2543 | 2566 | let enum =
|
2544 | 2567 | Base.Option.(
|
2545 | 2568 | mk_enum (UnionEnumSet.empty, tag_of_member t0) (t0 :: t1 :: ts) >>| fun (tset, tag) ->
|
2546 | 2569 | EnumUnion (tset, tag)
|
2547 | 2570 | )
|
2548 | 2571 | in
|
2549 |
| -{ t0; t1; ts; source_aloc; specialization = ref enum; synthetic } |
| 2572 | +{ t0; t1; ts; source_aloc; specialization = ref enum; kind } |
2550 | 2573 |
|
2551 | 2574 | let members { t0; t1; ts; _ } = t0 :: t1 :: ts
|
2552 | 2575 |
|
@@ -2559,7 +2582,8 @@ end = struct
|
2559 | 2582 | | t0 :: t1 :: ts -> make t0 t1 ts
|
2560 | 2583 | | _ -> failwith "impossible"
|
2561 | 2584 |
|
2562 |
| -let ident_map ?(always_keep_source = false) f ({ t0; t1; ts; source_aloc = source; _ } as rep) = |
| 2585 | +let ident_map |
| 2586 | +?(always_keep_source = false) f ({ t0; t1; ts; source_aloc = source; kind; _ } as rep) = |
2563 | 2587 | let t0_ = f t0 in
|
2564 | 2588 | let t1_ = f t1 in
|
2565 | 2589 | let ts_ = ListUtils.ident_map f ts in
|
@@ -2571,7 +2595,7 @@ end = struct
|
2571 | 2595 | else
|
2572 | 2596 | None
|
2573 | 2597 | in
|
2574 |
| -make ?source_aloc t0_ t1_ ts_ |
| 2598 | +make ?source_aloc ~kind t0_ t1_ ts_ |
2575 | 2599 | else
|
2576 | 2600 | rep
|
2577 | 2601 |
|
|
0 commit comments