sun::ast::TypeParameter
struct · Source (opens in a new tab)
struct sun::ast::TypeParameterOne generic type parameter, as written between the angle brackets: a name, and optionally a constraint the type argument must satisfy.
<T> name "T", no constraint — any type <T: _Numeric> see TypeConstraint for the forms a constraint can take
The constraint is checked when the generic is instantiated with a concrete type argument, by the same predicate _is<T> uses in a function body.
Public Functions
TypeParameter
TypeParameter()=default
public · function · Source (opens in a new tab)
sun::ast::TypeParameter::TypeParameter()=defaultCreates a named generic parameter with its optional type constraint.
TypeParameter(std::string n, std::optional< TypeConstraint > c=std::nullopt)
public · function · Source (opens in a new tab)
sun::ast::TypeParameter::TypeParameter(std::string n, std::optional< TypeConstraint > c=std::nullopt)Creates a named generic parameter with its optional type constraint.
Related: TypeConstraint
operator==
public · function · Source (opens in a new tab)
bool sun::ast::TypeParameter::operator==(const TypeParameter &other) constCompares the stored values for equality.
Related: TypeParameter
toString
public · function · Source (opens in a new tab)
std::string sun::ast::TypeParameter::toString() constT, or T: _Numeric — how the parameter reads in source.
toSunType
public · function · Source (opens in a new tab)
sun::types::TypePtr sun::ast::TypeParameter::toSunType(const sun::semantic_analysis::DeclarationTable &table, sun::semantic_analysis::DeclarationId id) constThe semantic type this parameter stands for while its generic is analyzed unspecialized: T bound to itself, carrying its constraint so a body can reach the constraint's members.
Unconstrained parameters carry none.
Related: sun::types::TypePtr, sun::semantic_analysis::DeclarationTable, sun::semantic_analysis::DeclarationId
Public Fields
constraint
public · variable · Source (opens in a new tab)
std::optional<TypeConstraint> sun::ast::TypeParameter::constraintNo documentation comment.
Related: TypeConstraint
name
public · variable · Source (opens in a new tab)
std::string sun::ast::TypeParameter::nameNo documentation comment.