Table of Contents

Class TypeRelations

Namespace
MuLang.Core.Types
Assembly
MuLang.Core.dll

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

left TypeSymbol

The first type.

right TypeSymbol

The second type.

Returns

bool

true if 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

source TypeSymbol

The source type.

target TypeSymbol

The 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

left TypeSymbol

The first type.

right TypeSymbol

The second type.

Returns

TypeSymbol

The common type, or null when 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

source TypeSymbol

The source type.

target TypeSymbol

The target type.

Returns

bool

true if 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

source TypeSymbol

The source type.

target TypeSymbol

The target type.

Returns

bool

true if a checked cast from the source type to the target type is permitted; otherwise, false.

Exceptions

ArgumentNullException

Thrown when either type is null.