KT-11588 Type aliases
- Nested type aliases - UNSUPPORTED_TYPEALIAS error (language level < 1.1) - tests for is/as/as? with type alias
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
typealias S = String
|
||||
|
||||
fun test1(x: Any) = x is S
|
||||
fun test2(x: Any) = x as S
|
||||
fun test3(x: Any) = x as? S
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public typealias S = kotlin.String
|
||||
public fun test1(/*0*/ x: kotlin.Any): kotlin.Boolean
|
||||
public fun test2(/*0*/ x: kotlin.Any): S [= kotlin.String]
|
||||
public fun test3(/*0*/ x: kotlin.Any): S [= kotlin.String?]
|
||||
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
class Pair<T1, T2>(val x1: T1, val x2: T2)
|
||||
|
||||
class C {
|
||||
typealias P2 = Pair<Int, Int>
|
||||
|
||||
fun p() = P2(1, 1)
|
||||
fun first(p: P2) = p.x1
|
||||
fun second(p: P2) = p.x2
|
||||
}
|
||||
|
||||
val p1 = Pair(1, 1)
|
||||
|
||||
val test1: Int = C().first(p1)
|
||||
val test2: Int = C().second(p1)
|
||||
|
||||
fun C.testExtFun1(x: C.P2) = x
|
||||
|
||||
fun C.testExtFun2(): C.P2 {
|
||||
val x: C.P2 = p()
|
||||
val y = C.P2(1, 1)
|
||||
return x
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package
|
||||
|
||||
public val p1: Pair<kotlin.Int, kotlin.Int>
|
||||
public val test1: kotlin.Int
|
||||
public val test2: kotlin.Int
|
||||
public fun C.testExtFun1(/*0*/ x: C.P2 [= Pair<kotlin.Int, kotlin.Int>]): C.P2 [= Pair<kotlin.Int, kotlin.Int>]
|
||||
public fun C.testExtFun2(): C.P2 [= Pair<kotlin.Int, kotlin.Int>]
|
||||
|
||||
public final class C {
|
||||
public typealias P2 = Pair<kotlin.Int, kotlin.Int>
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun first(/*0*/ p: C.P2 [= Pair<kotlin.Int, kotlin.Int>]): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun p(): Pair<kotlin.Int, kotlin.Int>
|
||||
public final fun second(/*0*/ p: C.P2 [= Pair<kotlin.Int, kotlin.Int>]): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Pair</*0*/ T1, /*1*/ T2> {
|
||||
public constructor Pair</*0*/ T1, /*1*/ T2>(/*0*/ x1: T1, /*1*/ x2: T2)
|
||||
public final val x1: T1
|
||||
public final val x2: T2
|
||||
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
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
class Pair<T1, T2>(val x1: T1, val x2: T2)
|
||||
|
||||
class C<T> {
|
||||
typealias P2 = Pair<T, T>
|
||||
typealias PT2<T2> = Pair<T, T2>
|
||||
|
||||
fun first(p: P2) = p.x1
|
||||
fun second(p: P2) = p.x2
|
||||
|
||||
fun <T2> first2(p: PT2<T2>) = p.x1
|
||||
fun <T2> second2(p: PT2<T2>) = p.x2
|
||||
}
|
||||
|
||||
val p1 = Pair(1, 1)
|
||||
val p2 = Pair(1, "")
|
||||
|
||||
val test1: Int = C<Int>().first(p1)
|
||||
val test2: Int = C<Int>().second(p1)
|
||||
|
||||
val test3: Int = C<Int>().first2(p2)
|
||||
val test4: String = C<Int>().second2(p2)
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public val p1: Pair<kotlin.Int, kotlin.Int>
|
||||
public val p2: Pair<kotlin.Int, kotlin.String>
|
||||
public val test1: kotlin.Int
|
||||
public val test2: kotlin.Int
|
||||
public val test3: kotlin.Int
|
||||
public val test4: kotlin.String
|
||||
|
||||
public final class C</*0*/ T> {
|
||||
public typealias P2 /*captured type parameters: /*0*/ T*/ = Pair<T, T>
|
||||
public typealias PT2</*0*/ T2> /*captured type parameters: /*1*/ T*/ = Pair<T, T2>
|
||||
public constructor C</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun first(/*0*/ p: C<T>.P2 [= Pair<T, T>]): T
|
||||
public final fun </*0*/ T2> first2(/*0*/ p: C<T>.PT2<T2> [= Pair<T, T2>]): T
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun second(/*0*/ p: C<T>.P2 [= Pair<T, T>]): T
|
||||
public final fun </*0*/ T2> second2(/*0*/ p: C<T>.PT2<T2> [= Pair<T, T2>]): T2
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Pair</*0*/ T1, /*1*/ T2> {
|
||||
public constructor Pair</*0*/ T1, /*1*/ T2>(/*0*/ x1: T1, /*1*/ x2: T2)
|
||||
public final val x1: T1
|
||||
public final val x2: T2
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
class Pair<T1, T2>(val x1: T1, val x2: T2)
|
||||
|
||||
class C<T> {
|
||||
typealias P2 = Pair<T, Int>
|
||||
}
|
||||
|
||||
val p1: C<String>.P2 = Pair("", 1)
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public val p1: C<kotlin.String>.P2 [= Pair<kotlin.String, kotlin.Int>]
|
||||
|
||||
public final class C</*0*/ T> {
|
||||
public typealias P2 /*captured type parameters: /*0*/ T*/ = Pair<T, kotlin.Int>
|
||||
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 final class Pair</*0*/ T1, /*1*/ T2> {
|
||||
public constructor Pair</*0*/ T1, /*1*/ T2>(/*0*/ x1: T1, /*1*/ x2: T2)
|
||||
public final val x1: T1
|
||||
public final val x2: T2
|
||||
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
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
typealias A = B
|
||||
typealias B = A
|
||||
typealias A = <!RECURSIVE_TYPEALIAS_EXPANSION!>B<!>
|
||||
typealias B = <!RECURSIVE_TYPEALIAS_EXPANSION!>A<!>
|
||||
|
||||
val x: <!RECURSIVE_TYPEALIAS_EXPANSION!>A<!> = TODO()
|
||||
@@ -3,13 +3,13 @@ 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 In2<T> = In<<!REDUNDANT_PROJECTION, REDUNDANT_PROJECTION!>in<!> T>
|
||||
typealias In3<T> = In<<!CONFLICTING_PROJECTION, 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 Out2<T> = Out<<!CONFLICTING_PROJECTION, CONFLICTING_PROJECTION!>in<!> T>
|
||||
typealias Out3<T> = Out<<!REDUNDANT_PROJECTION, REDUNDANT_PROJECTION!>out<!> T>
|
||||
typealias Out4<T> = Out<*>
|
||||
|
||||
typealias Inv1<T> = Inv<T>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: -TypeAliases
|
||||
|
||||
class C
|
||||
|
||||
<!UNSUPPORTED_TYPEALIAS!>typealias<!> S = String
|
||||
<!UNSUPPORTED_TYPEALIAS!>typealias<!> L<T> = List<T>
|
||||
<!UNSUPPORTED_TYPEALIAS!>typealias<!> CA = C
|
||||
|
||||
val test1: <!UNRESOLVED_REFERENCE!>S<!> = ""
|
||||
|
||||
fun test2(x: <!UNRESOLVED_REFERENCE!>L<!><<!UNRESOLVED_REFERENCE!>S<!>>) = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
|
||||
|
||||
class Test3 : <!UNRESOLVED_REFERENCE!>CA<!>()
|
||||
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
public val test1: [ERROR : S]
|
||||
public fun test2(/*0*/ x: [ERROR : L<S>]<[ERROR : S]>): [ERROR : L<S>]<[ERROR : S]>
|
||||
|
||||
public final class C {
|
||||
public constructor C()
|
||||
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 Test3 {
|
||||
public constructor Test3()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
open class Pair<T1, T2>
|
||||
open class Triple<T1, T2, T3>
|
||||
|
||||
class Outer<X> {
|
||||
inner class InnerTest1<A>: Pair<X, A>()
|
||||
typealias Test1<A> = Pair<X, A>
|
||||
|
||||
class Nested<Y> {
|
||||
typealias Test2<B> = Pair<Y, B>
|
||||
}
|
||||
|
||||
inner class Inner<Z> {
|
||||
typealias Test3<C> = Triple<X, Z, C>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package test
|
||||
|
||||
public final class Outer</*0*/ X> {
|
||||
public typealias Test1</*0*/ A> /*captured type parameters: /*1*/ X*/ = test.Pair<X, A>
|
||||
/*primary*/ public constructor Outer</*0*/ X>()
|
||||
|
||||
public final inner class Inner</*0*/ Z> /*captured type parameters: /*1*/ X*/ {
|
||||
public typealias Test3</*0*/ C> /*captured type parameters: /*1*/ Z, /*2*/ X*/ = test.Triple<X, Z, C>
|
||||
/*primary*/ public constructor Inner</*0*/ Z>()
|
||||
}
|
||||
|
||||
public final inner class InnerTest1</*0*/ A> /*captured type parameters: /*1*/ X*/ : test.Pair<X, A> {
|
||||
/*primary*/ public constructor InnerTest1</*0*/ A>()
|
||||
}
|
||||
|
||||
public final class Nested</*0*/ Y> {
|
||||
public typealias Test2</*0*/ B> /*captured type parameters: /*1*/ Y*/ = test.Pair<Y, B>
|
||||
/*primary*/ public constructor Nested</*0*/ Y>()
|
||||
}
|
||||
}
|
||||
|
||||
public open class Pair</*0*/ T1, /*1*/ T2> {
|
||||
/*primary*/ public constructor Pair</*0*/ T1, /*1*/ T2>()
|
||||
}
|
||||
|
||||
public open class Triple</*0*/ T1, /*1*/ T2, /*2*/ T3> {
|
||||
/*primary*/ public constructor Triple</*0*/ T1, /*1*/ T2, /*2*/ T3>()
|
||||
}
|
||||
Reference in New Issue
Block a user