KaTypeRelationChecker¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaTypeRelationChecker : KaSessionComponent
Inheritors¶
Properties¶
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
Functions¶
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
isSubtypeOf¶
abstract fun KaType.isSubtypeOf(supertype: KaType, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean
abstract fun KaType.isSubtypeOf(classId: ClassId, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean
Returns whether this KaType is a subtype of a class called classId.
This function provides a convenient way to check if a class extends a certain base class or interface while disregarding type arguments. For example, one may check if this KaType is a subtype of StandardClassIds.Iterable.
The errorTypePolicy is applied as such: If this KaType is an error type, the LENIENT policy leads to a trivially true result. Errors in type arguments are not considered, as the subclass check is concerned with the applied class type and not its type arguments.
This function for ClassIds is a convenient dual to other isSubtypeOf functions. As such, its result is the same as a call to isSubtypeOf with the following right-hand KaType: a.b.Class<*, *, ...>? given a class ID a.b.Class with all type arguments instantiated to a star projection.
This has the following interesting implications:
-
If the
classIdpoints to or actualizes to a type alias, subclassing is checked for the expanded type, as otherisSubtypeOfimplementations also take expansion into account. If the type alias doesn't expand to aKaClassType,isSubtypeOfis triviallyfalse. -
If the
classIdcannot be resolved, it effectively means that we would have an "unresolved symbol" errorKaTypeon the right-hand side ofisSubtypeOf. Hence, with aLENIENTerror type policy,isSubtypeOfistruefor all unresolved class IDs.
abstract fun KaType.isSubtypeOf(symbol: KaClassLikeSymbol, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean
Returns whether this KaType is a subtype of a class represented by symbol.
This function provides a convenient way to check if a class extends a certain base class or interface while disregarding type arguments.
The errorTypePolicy is applied as such: If this KaType is an error type, the LENIENT policy leads to a trivially true result. Errors in type arguments are not considered, as the subclass check is concerned with the applied class type and not its type arguments.
This function for KaClassLikeSymbols is a convenient dual to other isSubtypeOf functions. As such, its result is the same as a call to isSubtypeOf with the following right-hand KaType: a.b.Class<*, *, ...>? given a class called a.b.Class with all type arguments instantiated to a star projection.
This has the following interesting implication: If the symbol points to or actualizes to a type alias, subclassing is checked for the expanded type, as other isSubtypeOf implementations also take expansion into account. If the type alias doesn't expand to a KaClassType, isSubtypeOf is trivially false.
isValid¶
fun KaLifetimeOwner.isValid(): Boolean
Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.
semanticallyEquals¶
abstract fun KaType.semanticallyEquals(other: KaType, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean
Returns whether this KaType is semantically equal to other.
Semantic equality stands in contrast to the structural equality implemented by KaType.equals. See KaType for a detailed discussion about structural vs. semantic type equality.
withValidityAssertion¶
inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R
Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.