KT-11588 Type aliases
Resolution & expansion for type aliases. NB: Nested type aliases capturing type parameters of outer classes are not supported yet.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
typealias S = String
|
||||
|
||||
val OK: S = "OK"
|
||||
|
||||
fun box(): S = OK
|
||||
@@ -0,0 +1,5 @@
|
||||
typealias WithVariance<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> X, <!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> Y> = Int
|
||||
typealias WithBounds1<T : <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>T<!>> = Int
|
||||
typealias WithBounds2<X : <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>Y<!>, Y : <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>X<!>> = Int
|
||||
|
||||
val x: WithVariance<Int, Int> = 0
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public val x: WithVariance<kotlin.Int, kotlin.Int> [= kotlin.Int] = 0
|
||||
public typealias WithBounds1</*0*/ T : [ERROR : Cyclic upper bounds]> = kotlin.Int
|
||||
public typealias WithBounds2</*0*/ X : [ERROR : Cyclic upper bounds], /*1*/ Y : [ERROR : Cyclic upper bounds]> = kotlin.Int
|
||||
public typealias WithVariance</*0*/ in X, /*1*/ out Y> = kotlin.Int
|
||||
@@ -0,0 +1,8 @@
|
||||
class C<T>
|
||||
|
||||
typealias CA<T> = C<T>
|
||||
|
||||
val ca1: CA<Int> = C<Int>()
|
||||
val ca2: CA<CA<Int>> = C<C<Int>>()
|
||||
val ca3: CA<C<Int>> = C<C<Int>>()
|
||||
val ca4: CA<Int?> = C<Int?>()
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public val ca1: CA<kotlin.Int> [= C<kotlin.Int>]
|
||||
public val ca2: CA<CA<kotlin.Int> [= C<kotlin.Int>]> [= C<CA<kotlin.Int> [= C<kotlin.Int>]>]
|
||||
public val ca3: CA<C<kotlin.Int>> [= C<C<kotlin.Int>>]
|
||||
public val ca4: CA<kotlin.Int?> [= C<kotlin.Int?>]
|
||||
|
||||
public final class C</*0*/ T> {
|
||||
public constructor C</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias CA</*0*/ T> = C<T>
|
||||
@@ -0,0 +1,4 @@
|
||||
typealias A = B
|
||||
typealias B = A
|
||||
|
||||
val x: <!RECURSIVE_TYPEALIAS_EXPANSION!>A<!> = TODO()
|
||||
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public val x: [ERROR : Recursive type alias: A]
|
||||
public typealias A = B
|
||||
public typealias B = A
|
||||
@@ -0,0 +1,8 @@
|
||||
typealias S = String
|
||||
typealias SS = S
|
||||
typealias SSS = SS
|
||||
|
||||
val s1: SSS = ""
|
||||
val s2: SSS? = null
|
||||
val s3: List<SSS>? = null
|
||||
val s4: List<List<SSS>?>? = null
|
||||
@@ -0,0 +1,9 @@
|
||||
package
|
||||
|
||||
public val s1: SSS [= kotlin.String] = ""
|
||||
public val s2: SSS [= kotlin.String?] = null
|
||||
public val s3: kotlin.collections.List<SSS [= kotlin.String]>? = null
|
||||
public val s4: kotlin.collections.List<kotlin.collections.List<SSS [= kotlin.String]>?>? = null
|
||||
public typealias S = kotlin.String
|
||||
public typealias SS = S
|
||||
public typealias SSS = SS
|
||||
@@ -0,0 +1,20 @@
|
||||
class In<in T>
|
||||
class Out<out T>
|
||||
class Inv<T>
|
||||
|
||||
typealias In1<T> = In<T>
|
||||
typealias In2<T> = In<<!REDUNDANT_PROJECTION!>in<!> T>
|
||||
typealias In3<T> = In<<!CONFLICTING_PROJECTION!>out<!> T>
|
||||
typealias In4<T> = In<*>
|
||||
|
||||
typealias Out1<T> = Out<T>
|
||||
typealias Out2<T> = Out<<!CONFLICTING_PROJECTION!>in<!> T>
|
||||
typealias Out3<T> = Out<<!REDUNDANT_PROJECTION!>out<!> T>
|
||||
typealias Out4<T> = Out<*>
|
||||
|
||||
typealias Inv1<T> = Inv<T>
|
||||
typealias Inv2<T> = Inv<in T>
|
||||
typealias Inv3<T> = Inv<out T>
|
||||
typealias Inv4<T> = Inv<*>
|
||||
|
||||
val inv1: Inv1<Int> = Inv<Int>()
|
||||
@@ -0,0 +1,36 @@
|
||||
package
|
||||
|
||||
public val inv1: Inv1<kotlin.Int> [= Inv<kotlin.Int>]
|
||||
|
||||
public final class In</*0*/ in T> {
|
||||
public constructor In</*0*/ in T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out T> {
|
||||
public constructor Out</*0*/ out T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias In1</*0*/ T> = In<T>
|
||||
public typealias In2</*0*/ T> = In<in T>
|
||||
public typealias In3</*0*/ T> = In<out T>
|
||||
public typealias In4</*0*/ T> = In<*>
|
||||
public typealias Inv1</*0*/ T> = Inv<T>
|
||||
public typealias Inv2</*0*/ T> = Inv<in T>
|
||||
public typealias Inv3</*0*/ T> = Inv<out T>
|
||||
public typealias Inv4</*0*/ T> = Inv<*>
|
||||
public typealias Out1</*0*/ T> = Out<T>
|
||||
public typealias Out2</*0*/ T> = Out<in T>
|
||||
public typealias Out3</*0*/ T> = Out<out T>
|
||||
public typealias Out4</*0*/ T> = Out<*>
|
||||
Reference in New Issue
Block a user