Skip to content

ASSIGN_LEFT

Requires that there exists an instantiation of the left type parameters such that the left type is a subtype of the right type when substituted. Type parameters of the right type are treated as fixed.

The constructed substitutor contains mappings for all type parameters of the left type such that the substituted left type is a subtype of the right type. If a correct instantiation doesn't exist, no substitutor is produced.

Examples:

interface A<T> : B<T>
interface B<T> : C<Int, T>
interface C<X, Y>

fun <K> test(leftType: A<K>, rightType: C<Int, String>) {}

The left type here is generic A<K> and the right type is a fixed supertype C<Int, String>. For this case, ASSIGN_LEFT will produce { K -> String } as with such a substitution, A<String> is a subtype of C<Int, String>.

fun <T, R: Int> example(leftType: List<T>, rightType: List<R>) {}

ASSIGN_LEFT produces { T -> R } mapping as with such a substitution, List<T> is a subtype of List<R>.

fun <T: Number> example(leftType: Number, rightType: T) {}

There are no free type parameters as the left type Number is concrete. T is not guaranteed to be exactly Number to satisfy the constraint (e.g., with { T -> kotlin/Int }), so ASSIGN_LEFT produces no substitutor.

Properties

name

val name: String

ordinal

val ordinal: Int