diff --git a/src/analysis/type_utils.ml b/src/analysis/type_utils.ml index 99872f324..b5d089360 100644 --- a/src/analysis/type_utils.ml +++ b/src/analysis/type_utils.ml @@ -215,13 +215,15 @@ let print_type_with_decl ~verbosity env ppf typ = Env.with_cmis @@ fun () -> Env.find_type path env in - let is_abstract = Btype.type_kind_is_abstract decl in - (* Print expression only if it is parameterized or abstract *) - let print_expr = is_abstract || params <> [] in + (* Print expression in addition to the type declaration + only if it is parameterized. *) + let print_expr = params <> [] in if print_expr then Printtyp.type_scheme env ppf typ; - (* If not abstract, also print the declaration *) - if not is_abstract then + (* Jane Street only: print the declaration even if it's + abstract, because this gives us a place to print + the inferred layout annotation. + *) begin (* Separator if expression was printed *) if print_expr then diff --git a/tests/test-dirs/type-enclosing/jane-street.t/run.t b/tests/test-dirs/type-enclosing/jane-street.t/run.t index 87f7bd374..500c17c90 100644 --- a/tests/test-dirs/type-enclosing/jane-street.t/run.t +++ b/tests/test-dirs/type-enclosing/jane-street.t/run.t @@ -101,12 +101,12 @@ to print everything on one line. let f0 (x : t0) = x ^ With verbosity 0: "t0" - With verbosity 1: "int" + With verbosity 1: "type t0 : immediate = int" let f1 (x : t1) = x ^ With verbosity 0: "t1" - With verbosity 1: "int" + With verbosity 1: "type t1 : immediate = int" let f2 (x : t2) = x ^ @@ -159,17 +159,17 @@ to print everything on one line. let poly1 (type a) (x : a) = x ^ With verbosity 0: "a" - With verbosity 1: "a" + With verbosity 1: "type a : value" let poly2 (type a : value) (x : a) = x ^ With verbosity 0: "a" - With verbosity 1: "a" + With verbosity 1: "type a : value" let poly3 (type a : float64) (x : a) = x ^ With verbosity 0: "a" - With verbosity 1: "a" + With verbosity 1: "type a : float64" let poly4 (type (a : immediate) (b : value)) (f : a -> b -> _) = f ^ diff --git a/tests/test-dirs/type-enclosing/variants.t/run.t b/tests/test-dirs/type-enclosing/variants.t/run.t index c237c464e..914102337 100644 --- a/tests/test-dirs/type-enclosing/variants.t/run.t +++ b/tests/test-dirs/type-enclosing/variants.t/run.t @@ -85,7 +85,7 @@ "line": 4, "col": 5 }, - "type": "[ `A | `B | `C ]", + "type": "type more : immediate = [ `A | `B | `C ]", "tail": "no" } ] @@ -195,7 +195,7 @@ FIXME: Not satisfying, expected core not more "line": 9, "col": 7 }, - "type": "[ `A | `B | `C ]", + "type": "type more : immediate = [ `A | `B | `C ]", "tail": "no" }, {