1 // Copyright (c) Facebook, Inc. and its affiliates.
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
6 // @generated SignedSource<<30b35198b2ff91df27f01498536e02bd>>
8 // To regenerate this file, run:
9 // hphp/hack/src/oxidized_regen.sh
11 use arena_trait::TrivialDrop;
12 use no_pos_hash::NoPosHash;
13 use ocamlrep_derive::FromOcamlRep;
14 use ocamlrep_derive::FromOcamlRepIn;
15 use ocamlrep_derive::ToOcamlRep;
18 #[allow(unused_imports)]
21 pub use crate::t_shape_map;
22 pub use crate::typing_reason as reason;
39 pub &'a pos_or_decl::PosOrDecl<'a>,
40 pub &'a ast_defs::Id_<'a>,
42 impl<'a> TrivialDrop for PosId<'a> {}
58 pub enum CeVisibility<'a> {
63 impl<'a> TrivialDrop for CeVisibility<'a> {}
79 pub enum IfcFunDecl<'a> {
80 FDPolicied(Option<&'a str>),
83 impl<'a> TrivialDrop for IfcFunDecl<'a> {}
104 impl TrivialDrop for Exact {}
126 impl TrivialDrop for ValKind {}
143 pub enum FunTparamsKind {
144 /// If ft_tparams is empty, the containing fun_type is a concrete function type.
145 /// Otherwise, it is a generic function and ft_tparams specifies its type parameters.
147 /// The containing fun_type is a concrete function type which is an
148 /// instantiation of a generic function with at least one reified type
149 /// parameter. This means that the function requires explicit type arguments
150 /// at every invocation, and ft_tparams specifies the type arguments with
151 /// which the generic function was instantiated, as well as whether each
152 /// explicit type argument must be reified.
153 FTKinstantiatedTargs,
155 impl TrivialDrop for FunTparamsKind {}
176 impl TrivialDrop for ShapeKind {}
192 pub struct PosString<'a>(pub &'a pos_or_decl::PosOrDecl<'a>, pub &'a str);
193 impl<'a> TrivialDrop for PosString<'a> {}
195 pub type TByteString<'a> = str;
211 pub struct PosByteString<'a>(pub &'a pos_or_decl::PosOrDecl<'a>, pub &'a bstr::BStr);
212 impl<'a> TrivialDrop for PosByteString<'a> {}
228 pub enum TshapeFieldName<'a> {
229 TSFlitInt(&'a PosString<'a>),
230 TSFlitStr(&'a PosByteString<'a>),
231 TSFclassConst(&'a (PosId<'a>, PosString<'a>)),
233 impl<'a> TrivialDrop for TshapeFieldName<'a> {}
254 impl TrivialDrop for ParamMode {}
271 pub enum XhpAttrTag {
275 impl TrivialDrop for XhpAttrTag {}
292 pub tag: Option<XhpAttrTag>,
293 pub has_default: bool,
295 impl TrivialDrop for XhpAttr {}
297 /// Denotes the categories of requirements we apply to constructor overrides.
299 /// In the default case, we use Inconsistent. If a class has <<__ConsistentConstruct>>,
300 /// or if it inherits a class that has <<__ConsistentConstruct>>, we use inherited.
301 /// If we have a new final class that doesn't extend from <<__ConsistentConstruct>>,
302 /// then we use Final. Only classes that are Inconsistent or Final can have reified
319 pub enum ConsistentKind {
324 impl TrivialDrop for ConsistentKind {}
340 pub enum DependentType {
342 DTexpr(ident::Ident),
344 impl TrivialDrop for DependentType {}
359 pub struct UserAttribute<'a> {
361 pub classname_params: &'a [&'a str],
363 impl<'a> TrivialDrop for UserAttribute<'a> {}
378 pub struct Tparam<'a> {
379 pub variance: oxidized::ast_defs::Variance,
381 pub tparams: &'a [&'a Tparam<'a>],
382 pub constraints: &'a [(oxidized::ast_defs::ConstraintKind, &'a Ty<'a>)],
383 pub reified: oxidized::aast::ReifyKind,
384 pub user_attributes: &'a [&'a UserAttribute<'a>],
386 impl<'a> TrivialDrop for Tparam<'a> {}
401 pub struct WhereConstraint<'a>(
403 pub oxidized::ast_defs::ConstraintKind,
406 impl<'a> TrivialDrop for WhereConstraint<'a> {}
408 #[derive(Clone, Debug, FromOcamlRepIn, Hash, NoPosHash, Serialize, ToOcamlRep)]
409 pub struct Ty<'a>(pub &'a reason::Reason<'a>, pub Ty_<'a>);
410 impl<'a> TrivialDrop for Ty<'a> {}
412 /// A shape may specify whether or not fields are required. For example, consider
416 /// type ShapeWithOptionalField = shape(?'a' => ?int);
419 /// With this definition, the field 'a' may be unprovided in a shape. In this
420 /// case, the field 'a' would have sf_optional set to true.
434 pub struct ShapeFieldType<'a> {
438 impl<'a> TrivialDrop for ShapeFieldType<'a> {}
454 /// The late static bound type of a class
456 /// Either an object type or a type alias, ty list are the arguments
457 Tapply(&'a (PosId<'a>, &'a [&'a Ty<'a>])),
458 /// "Any" is the type of a variable with a missing annotation, and "mixed" is
459 /// the type of a variable annotated as "mixed". THESE TWO ARE VERY DIFFERENT!
460 /// Any unifies with anything, i.e., it is both a supertype and subtype of any
461 /// other type. You can do literally anything to it; it's the "trust me" type.
462 /// Mixed, on the other hand, is only a supertype of everything. You need to do
463 /// a case analysis to figure out what it is (i.e., its elimination form).
465 /// Here's an example to demonstrate:
468 /// function f($x): int {
473 /// In that example, $x has type Tany. This unifies with anything, so adding
474 /// one to it is allowed, and returning that as int is allowed.
476 /// In contrast, if $x were annotated as mixed, adding one to that would be
477 /// a type error -- mixed is not a subtype of int, and you must be a subtype
478 /// of int to take part in addition. (The converse is true though -- int is a
479 /// subtype of mixed.) A case analysis would need to be done on $x, via
480 /// is_int or similar.
482 /// mixed exists only in the decl_phase phase because it is desugared into ?nonnull
483 /// during the localization phase.
486 Tany(tany_sentinel::TanySentinel),
489 /// A dynamic type is a special type which sometimes behaves as if it were a
490 /// top type; roughly speaking, where a specific value of a particular type is
491 /// expected and that type is dynamic, anything can be given. We call this
492 /// behaviour "coercion", in that the types "coerce" to dynamic. In other ways it
493 /// behaves like a bottom type; it can be used in any sort of binary expression
494 /// or even have object methods called from it. However, it is in fact neither.
496 /// it captures dynamicism within function scope.
497 /// See tests in typecheck/dynamic/ for more examples.
499 /// Nullable, called "option" in the ML parlance.
501 /// All the primitive types: int, string, void, etc.
502 Tprim(&'a aast::Tprim),
503 /// A wrapper around fun_type, which contains the full type information for a
504 /// function, method, lambda, etc.
505 Tfun(&'a FunType<'a>),
506 /// Tuple, with ordered list of the types of the elements of the tuple.
507 Ttuple(&'a [&'a Ty<'a>]),
508 /// Whether all fields of this shape are known, types of each of the
513 t_shape_map::TShapeMap<'a, &'a ShapeFieldType<'a>>,
517 /// The type of a generic parameter. The constraints on a generic parameter
518 /// are accessed through the lenv.tpenv component of the environment, which
519 /// is set up when checking the body of a function or method. See uses of
520 /// Typing_phase.add_generic_parameters_and_constraints. The list denotes
522 Tgeneric(&'a (&'a str, &'a [&'a Ty<'a>])),
524 /// The values that are members of this type are the union of the values
525 /// that are members of the components of the union.
526 /// Some examples (writing | for binary union)
527 /// Tunion [] is the "nothing" type, with no values
528 /// Tunion [int;float] is the same as num
529 /// Tunion [null;t] is the same as Toption t
530 Tunion(&'a [&'a Ty<'a>]),
531 Tintersection(&'a [&'a Ty<'a>]),
532 /// Tdarray (ty1, ty2) => "darray<ty1, ty2>"
533 Tdarray(&'a (&'a Ty<'a>, &'a Ty<'a>)),
534 /// Tvarray (ty) => "varray<ty>"
536 /// Tvarray_or_darray (ty1, ty2) => "varray_or_darray<ty1, ty2>"
537 TvarrayOrDarray(&'a (&'a Ty<'a>, &'a Ty<'a>)),
538 /// Tvec_or_dict (ty1, ty2) => "vec_or_dict<ty1, ty2>"
539 TvecOrDict(&'a (&'a Ty<'a>, &'a Ty<'a>)),
540 /// Name of class, name of type const, remaining names of type consts
541 Taccess(&'a TaccessType<'a>),
542 /// This represents a type alias that lacks necessary type arguments. Given
543 /// type Foo<T1,T2> = ...
544 /// Tunappliedalias "Foo" stands for usages of plain Foo, without supplying
545 /// further type arguments. In particular, Tunappliedalias always stands for
546 /// a higher-kinded type. It is never used for an alias like
548 /// that simply doesn't require type arguments.
549 TunappliedAlias(&'a str),
550 /// The type of an opaque type or enum. Outside their defining files or
551 /// when they represent enums, they are "opaque", which means that they
552 /// only unify with themselves. Within a file, uses of newtypes are
553 /// expanded to their definitions (unless the newtype is an enum).
555 /// However, it is possible to have a constraint that allows us to relax
556 /// opaqueness. For example:
558 /// newtype MyType as int = ...
562 /// enum MyType: int as int { ... }
564 /// Outside of the file where the type was defined, this translates to:
566 /// Tnewtype ((pos, "MyType"), [], Tprim Tint)
568 /// which means that MyType is abstract, but is a subtype of int as well.
569 /// When the constraint is omitted, the third parameter is set to mixed.
571 /// The second parameter is the list of type arguments to the type.
572 Tnewtype(&'a (&'a str, &'a [&'a Ty<'a>], &'a Ty<'a>)),
573 /// see dependent_type
574 Tdependent(&'a (DependentType, &'a Ty<'a>)),
575 /// Tobject is an object type compatible with all objects. This type is also
576 /// compatible with some string operations (since a class might implement
577 /// __toString), but not with string type hints.
579 /// Tobject is currently used to type code like:
580 /// ../test/typecheck/return_unknown_class.php
582 /// An instance of a class or interface, ty list are the arguments
583 /// If exact=Exact, then this represents instances of *exactly* this class
584 /// If exact=Nonexact, this also includes subclasses
585 Tclass(&'a (PosId<'a>, Exact, &'a [&'a Ty<'a>])),
587 impl<'a> TrivialDrop for Ty_<'a> {}
602 pub struct TaccessType<'a>(pub &'a Ty<'a>, pub PosId<'a>);
603 impl<'a> TrivialDrop for TaccessType<'a> {}
619 pub enum Capability<'a> {
620 CapDefaults(&'a pos_or_decl::PosOrDecl<'a>),
623 impl<'a> TrivialDrop for Capability<'a> {}
625 /// Companion to fun_params type, intended to consolidate checking of
626 /// implicit params for functions.
640 pub struct FunImplicitParams<'a> {
641 pub capability: Capability<'a>,
643 impl<'a> TrivialDrop for FunImplicitParams<'a> {}
645 /// The type of a function AND a method.
646 /// A function has a min and max arity because of optional arguments
660 pub struct FunType<'a> {
661 pub arity: FunArity<'a>,
662 pub tparams: &'a [&'a Tparam<'a>],
663 pub where_constraints: &'a [&'a WhereConstraint<'a>],
664 pub params: &'a FunParams<'a>,
665 pub implicit_params: &'a FunImplicitParams<'a>,
666 /// Carries through the sync/async information from the aast
667 pub ret: &'a PossiblyEnforcedTy<'a>,
668 pub flags: typing_defs_flags::FunTypeFlags,
669 pub ifc_decl: IfcFunDecl<'a>,
671 impl<'a> TrivialDrop for FunType<'a> {}
673 /// Arity information for a fun_type; indicating the minimum number of
674 /// args expected by the function and the maximum number of args for
675 /// standard, non-variadic functions or the type of variadic argument taken
690 pub enum FunArity<'a> {
692 /// PHP5.6-style ...$args finishes the func declaration.
693 /// min ; variadic param type
694 Fvariadic(&'a FunParam<'a>),
696 impl<'a> TrivialDrop for FunArity<'a> {}
711 pub struct PossiblyEnforcedTy<'a> {
712 /// True if consumer of this type enforces it at runtime
714 pub type_: &'a Ty<'a>,
716 impl<'a> TrivialDrop for PossiblyEnforcedTy<'a> {}
731 pub struct FunParam<'a> {
732 pub pos: &'a pos_or_decl::PosOrDecl<'a>,
733 pub name: Option<&'a str>,
734 pub type_: &'a PossiblyEnforcedTy<'a>,
735 pub flags: typing_defs_flags::FunParamFlags,
737 impl<'a> TrivialDrop for FunParam<'a> {}
739 pub type FunParams<'a> = [&'a FunParam<'a>];
756 pub enum DestructureKind {
760 impl TrivialDrop for DestructureKind {}
775 pub struct Destructure<'a> {
776 /// This represents the standard parameters of a function or the fields in a list
777 /// destructuring assignment. Example:
779 /// function take(bool $b, float $f = 3.14, arraykey ...$aks): void {}
780 /// function f((bool, float, int, string) $tup): void {
784 /// corresponds to the subtyping assertion
786 /// (bool, float, int, string) <: splat([#1], [opt#2], ...#3)
787 pub required: &'a [&'a Ty<'a>],
788 /// Represents the optional parameters in a function, only used for splats
789 pub optional: &'a [&'a Ty<'a>],
790 /// Represents a function's variadic parameter, also only used for splats
791 pub variadic: Option<&'a Ty<'a>>,
792 /// list() destructuring allows for partial matches on lists, even when the operation
793 /// might throw i.e. list($a) = vec[];
794 pub kind: DestructureKind,
796 impl<'a> TrivialDrop for Destructure<'a> {}
811 pub struct HasMember<'a> {
812 pub name: nast::Sid<'a>,
813 pub type_: &'a Ty<'a>,
814 /// This is required to check ambiguous object access, where sometimes
815 /// HHVM would access the private member of a parent class instead of the
816 /// one from the current class.
817 pub class_id: &'a nast::ClassId_<'a>,
818 pub explicit_targs: Option<&'a [&'a nast::Targ<'a>]>,
820 impl<'a> TrivialDrop for HasMember<'a> {}
836 pub enum ConstraintType_<'a> {
837 ThasMember(&'a HasMember<'a>),
838 /// The type of container destructuring via list() or splat `...`
839 Tdestructure(&'a Destructure<'a>),
840 TCunion(&'a (&'a Ty<'a>, ConstraintType<'a>)),
841 TCintersection(&'a (&'a Ty<'a>, ConstraintType<'a>)),
843 impl<'a> TrivialDrop for ConstraintType_<'a> {}
855 pub struct ConstraintType<'a>(pub &'a reason::Reason<'a>, pub &'a ConstraintType_<'a>);
856 impl<'a> TrivialDrop for ConstraintType<'a> {}
872 pub enum InternalType<'a> {
873 LoclType(&'a Ty<'a>),
874 ConstraintType(ConstraintType<'a>),
876 impl<'a> TrivialDrop for InternalType<'a> {}