Class TypeRelations
Provides operations for comparing and converting MuLang types.
public static class TypeRelations
- Inheritance
-
TypeRelations
- Inherited Members
Methods
AreEquivalent(TypeSymbol, TypeSymbol)
Determines whether two types have equivalent structure and semantics.
public static bool AreEquivalent(TypeSymbol left, TypeSymbol right)
Parameters
leftTypeSymbolThe first type.
rightTypeSymbolThe second type.
Returns
- bool
trueif the types are equivalent; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when either type is
null.
ClassifyConversion(TypeSymbol, TypeSymbol)
Classifies a value conversion from one type to another, independently of checked casts.
public static ConversionKind ClassifyConversion(TypeSymbol source, TypeSymbol target)
Parameters
sourceTypeSymbolThe source type.
targetTypeSymbolThe target type.
Returns
- ConversionKind
The classified conversion kind.
Exceptions
- ArgumentNullException
Thrown when either type is
null.
GetCommonType(TypeSymbol, TypeSymbol)
Gets the most specific type that can represent values of both types.
public static TypeSymbol? GetCommonType(TypeSymbol left, TypeSymbol right)
Parameters
leftTypeSymbolThe first type.
rightTypeSymbolThe second type.
Returns
- TypeSymbol
The common type, or
nullwhen no common type exists.
Exceptions
- ArgumentNullException
Thrown when either type is
null.
IsAssignable(TypeSymbol, TypeSymbol)
Determines whether a value of one type can be assigned to another type.
public static bool IsAssignable(TypeSymbol source, TypeSymbol target)
Parameters
sourceTypeSymbolThe source type.
targetTypeSymbolThe target type.
Returns
- bool
trueif a value of the source type is assignable to the target type; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when either type is
null.
IsCastable(TypeSymbol, TypeSymbol)
Determines whether a value of one type can be checked for runtime conformance to another type.
public static bool IsCastable(TypeSymbol source, TypeSymbol target)
Parameters
sourceTypeSymbolThe source type.
targetTypeSymbolThe target type.
Returns
- bool
trueif a checked cast from the source type to the target type is permitted; otherwise,false.
Exceptions
- ArgumentNullException
Thrown when either type is
null.