Skip to content

Commit

Permalink
Add [@ocaml.principal] and [@ocaml.noprincipal] attributes, and use i…
Browse files Browse the repository at this point in the history
…n oo.mli
  • Loading branch information
stedolan committed Nov 19, 2021
1 parent 6d7d3b8 commit 74722cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions parsing/builtin_attributes.ml
Expand Up @@ -338,6 +338,15 @@ let clflags_attribute_with_int_payload attr ~name clflags_ref =
| None -> ()
end

let principal_attribute attr =
clflags_attribute_without_payload attr
~name:"principal" Clflags.principal

let noprincipal_attribute attr =
clflags_attribute_without_payload' attr
~name:"noprincipal"
~f:(fun () -> Clflags.principal := false)

let nolabels_attribute attr =
clflags_attribute_without_payload attr
~name:"nolabels" Clflags.classic
Expand Down Expand Up @@ -377,10 +386,14 @@ let afl_inst_ratio_attribute attr =

let parse_standard_interface_attributes attr =
warning_attribute attr;
principal_attribute attr;
noprincipal_attribute attr;
nolabels_attribute attr

let parse_standard_implementation_attributes attr =
warning_attribute attr;
principal_attribute attr;
noprincipal_attribute attr;
nolabels_attribute attr;
inline_attribute attr;
afl_inst_ratio_attribute attr;
Expand Down
2 changes: 2 additions & 0 deletions stdlib/oo.mli
Expand Up @@ -18,6 +18,8 @@ open! Stdlib

(** Operations on objects *)

[@@@ocaml.noprincipal] (* preserve structure sharing in copy (PR#9767) *)

val copy : (< .. > as 'a) -> 'a
(** [Oo.copy o] returns a copy of object [o], that is a fresh
object with the same methods and instance variables as [o]. *)
Expand Down

0 comments on commit 74722cb

Please sign in to comment.