@@ -7197,8 +7197,31 @@ let check_decl_jkind env decl jkind =
71977197 to expand only as much as needed, but the l/l subtype algorithm is tricky,
71987198 and so we leave this optimization for later. *)
71997199 let type_equal = type_equal env in
7200- let jkind_of_type ty = Some (type_jkind_purely env ty) in
7201- match Jkind. sub_jkind_l ~type_equal ~jkind_of_type decl.type_jkind jkind with
7200+ let type_jkind_purely = type_jkind_purely env in
7201+ let jkind_of_type ty = Some (type_jkind_purely ty) in
7202+ (* CR layouts v2.8: When we have [layout_of], this logic should move to the
7203+ place where [type_jkind] is set. But for now, it has to be here, because we
7204+ want this in module inclusion but not other places (because substitutions
7205+ won't improve the layout) *)
7206+ (* CR layouts v2.8: This improvement ignores types with both [@@unboxed]
7207+ and [@@unsafe_allow_any_mode_crossing], because the stdlib didn't build
7208+ otherwise. But we really shouldn't allow mixing those two features, and
7209+ so instead of trying to get to the bottom of it, I'm just punting. *)
7210+ let decl_jkind = match decl.type_kind, decl.type_manifest with
7211+ | Type_abstract _, Some inner_ty
7212+ (* These next cases are more properly rule TK_UNBOXED from kind-inference.md
7213+ (not rule FIND_ABBREV, as documented with [Jkind.for_abbreviation]), but
7214+ they should be fine here. This will all get fixed up later with the
7215+ above CRs. *)
7216+ | Type_record ([{ ld_type = inner_ty }], Record_unboxed , None ), _
7217+ | Type_record_unboxed_product ([{ ld_type = inner_ty }], _, None ), _
7218+ | Type_variant ([{ cd_args = (Cstr_tuple [{ ca_type = inner_ty }] |
7219+ Cstr_record [{ ld_type = inner_ty }]) }],
7220+ Variant_unboxed , None ), _ ->
7221+ Jkind. for_abbreviation ~type_jkind_purely inner_ty
7222+ | _ -> decl.type_jkind
7223+ in
7224+ match Jkind. sub_jkind_l ~type_equal ~jkind_of_type decl_jkind jkind with
72027225 | Ok () -> Ok ()
72037226 | Error _ as err ->
72047227 match decl.type_manifest with
0 commit comments