build_as_type: document why generic_instance can't be used (#9983)

master
Thomas Refis 2020-10-20 15:04:58 +02:00 committed by GitHub
parent 1e07bc7ed9
commit 10364b67d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -482,6 +482,11 @@ let rec build_as_type env p =
match extra with
| Tpat_type _ | Tpat_open _ | Tpat_unpack -> as_ty
| Tpat_constraint cty ->
(* [generic_instance] can only be used if the variables of the original
type ([cty.ctyp_type] here) are not at [generic_level], which they are
here.
If we used [generic_instance] we would lose the sharing between
[instance ty] and [ty]. *)
begin_def ();
let ty = instance cty.ctyp_type in
end_def ();