sun::ast::TypeConstraint
struct · Source (opens in a new tab)
struct sun::ast::TypeConstraintOne requirement written on a generic type parameter, after the colon:
<T: _Numeric> a built-in trait (see semantic_analysis/type_analysis/type_traits.h) <T: IShape> an interface the type argument must implement <T: IClone<T>> an interface with type arguments <F: _Lambda> any closure type
Parsing records the name, type arguments and source location. Deciding whether the name is a trait or an interface, and whether a given type argument satisfies it, is semantic analysis' job (sun::semantic_analysis::type_analysis::satisfies), which is what lets _is<T> in a body and a constraint on a signature answer with one vocabulary.
Public Functions
TypeConstraint
TypeConstraint(std::string n)
public · function · Source (opens in a new tab)
sun::ast::TypeConstraint::TypeConstraint(std::string n)Creates a named constraint on the types accepted by a generic parameter.
TypeConstraint()=default
public · function · Source (opens in a new tab)
sun::ast::TypeConstraint::TypeConstraint()=defaultCreates a named constraint on the types accepted by a generic parameter.
operator==
public · function · Source (opens in a new tab)
bool sun::ast::TypeConstraint::operator==(const TypeConstraint &other) constConstraints are compared by what they require, not by where they appear, so two spellings of the same requirement in different files are equal.
Related: TypeConstraint
toAnnotation
public · function · Source (opens in a new tab)
TypeAnnotation sun::ast::TypeConstraint::toAnnotation() constRepresent the required interface using ordinary type syntax.
Related: TypeAnnotation
toString
public · function · Source (opens in a new tab)
std::string sun::ast::TypeConstraint::toString() constRender the complete requirement for diagnostics.
Public Fields
declarationKey
public · variable · Source (opens in a new tab)
std::optional<sun::semantic_analysis::PortableDeclarationKey> sun::ast::TypeConstraint::declarationKeyNo documentation comment.
Related: sun::semantic_analysis::PortableDeclarationKey
name
public · variable · Source (opens in a new tab)
std::string sun::ast::TypeConstraint::nameNo documentation comment.
span
public · variable · Source (opens in a new tab)
sun::support::Position sun::ast::TypeConstraint::span {}No documentation comment.
Related: sun::support::Position
typeArguments
public · variable · Source (opens in a new tab)
std::vector<TypeAnnotation> sun::ast::TypeConstraint::typeArgumentsNo documentation comment.
Related: TypeAnnotation