getAwaitedType

abstract fun getAwaitedType(type: Type): Type?(source)

Gets the "awaited type" of a type.

If an expression has a Promise-like type, the "awaited type" of the expression is derived from the type of the first argument of the fulfillment callback for that Promise's then method. If the "awaited type" is itself a Promise-like, it is recursively unwrapped in the same manner until a non-promise type is found.

If an expression does not have a Promise-like type, its "awaited type" is the type of the expression.

If the resulting "awaited type" is a generic object type, then it is wrapped in an Awaited<T>.

In the event the "awaited type" circularly references itself, or is a non-Promise object-type with a callable then() method, an "awaited type" cannot be determined and the value undefined will be returned.

This is used to reflect the runtime behavior of the await keyword.