KT-11588 Type aliases

Diagnostics for type arguments substitution in type alias expansion
(initial implementation; TODO: refactor).
This commit is contained in:
Dmitry Petrov
2016-05-26 10:10:46 +03:00
parent 9cf8ef287e
commit e979300579
12 changed files with 275 additions and 18 deletions
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
class TColl<T, C : Collection<T>>
typealias TC<T1, T2> = TColl<T1, T2>
typealias TC2<T1, T2> = TC<T1, T2>
fun test1(x: TC2<Number, Collection<Number>>) {}
fun test2(x: TC2<Number, Collection<Int>>) {}
fun test3(x: TC2<Number, List<Int>>) {}
fun test4(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TC2<Number, List<Any>><!>) {}
val test5 = TC2<Number, Collection<Number>>()
val test6 = TC2<Number, Collection<Int>>()
val test7 = TC2<Number, List<Int>>()
val test8 = TC2<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>()
@@ -0,0 +1,19 @@
package
public typealias TC</*0*/ T1, /*1*/ T2> = TColl<T1, T2>
public typealias TC2</*0*/ T1, /*1*/ T2> = TC<T1, T2>
public val test5: TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Number>>
public val test6: TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Int>>
public val test7: TColl<kotlin.Number, kotlin.collections.List<kotlin.Int>>
public val test8: TColl<kotlin.Number, kotlin.collections.List<kotlin.Any>>
public fun test1(/*0*/ x: TC2<kotlin.Number, kotlin.collections.Collection<kotlin.Number>> [= TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Number>>]): kotlin.Unit
public fun test2(/*0*/ x: TC2<kotlin.Number, kotlin.collections.Collection<kotlin.Int>> [= TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Int>>]): kotlin.Unit
public fun test3(/*0*/ x: TC2<kotlin.Number, kotlin.collections.List<kotlin.Int>> [= TColl<kotlin.Number, kotlin.collections.List<kotlin.Int>>]): kotlin.Unit
public fun test4(/*0*/ x: TC2<kotlin.Number, kotlin.collections.List<kotlin.Any>> [= TColl<kotlin.Number, kotlin.collections.List<kotlin.Any>>]): kotlin.Unit
public final class TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<T>> {
public constructor TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<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
}
@@ -0,0 +1,29 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
class Num<T : Number>
class NumColl<T : Collection<Number>>
class TColl<T, C : Collection<T>>
typealias NA<T> = Num<T>
typealias NL<T> = NumColl<List<T>>
typealias TC<T1, T2> = TColl<T1, T2>
fun test1(x: NA<Int>) {}
fun test2(x: NA<<!UPPER_BOUND_VIOLATED!>Any<!>>) {}
fun test3(x: NL<Int>) {}
fun test4(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>NL<Any><!>) {}
val test5 = NA<Int>()
val test6 = NA<<!UPPER_BOUND_VIOLATED!>Any<!>>()
val test7 = NL<Int>()
val test8 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>NL<Any>()<!>
fun test9(x: TC<Number, Collection<Number>>) {}
fun test10(x: TC<Number, Collection<Int>>) {}
fun test11(x: TC<Number, List<Int>>) {}
fun test12(x: TC<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>) {}
val test13 = TC<Number, Collection<Number>>()
val test14 = TC<Number, Collection<Int>>()
val test15 = TC<Number, List<Int>>()
val test16 = TC<Number, <!UPPER_BOUND_VIOLATED!>List<Any><!>>()
@@ -0,0 +1,42 @@
package
public typealias NA</*0*/ T> = Num<T>
public typealias NL</*0*/ T> = NumColl<kotlin.collections.List<T>>
public typealias TC</*0*/ T1, /*1*/ T2> = TColl<T1, T2>
public val test13: TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Number>>
public val test14: TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Int>>
public val test15: TColl<kotlin.Number, kotlin.collections.List<kotlin.Int>>
public val test16: TColl<kotlin.Number, kotlin.collections.List<kotlin.Any>>
public val test5: Num<kotlin.Int>
public val test6: Num<kotlin.Any>
public val test7: NumColl<kotlin.collections.List<kotlin.Int>>
public val test8: NumColl<kotlin.collections.List<kotlin.Any>>
public fun test1(/*0*/ x: NA<kotlin.Int> [= Num<kotlin.Int>]): kotlin.Unit
public fun test10(/*0*/ x: TC<kotlin.Number, kotlin.collections.Collection<kotlin.Int>> [= TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Int>>]): kotlin.Unit
public fun test11(/*0*/ x: TC<kotlin.Number, kotlin.collections.List<kotlin.Int>> [= TColl<kotlin.Number, kotlin.collections.List<kotlin.Int>>]): kotlin.Unit
public fun test12(/*0*/ x: TC<kotlin.Number, kotlin.collections.List<kotlin.Any>> [= TColl<kotlin.Number, kotlin.collections.List<kotlin.Any>>]): kotlin.Unit
public fun test2(/*0*/ x: NA<kotlin.Any> [= Num<kotlin.Any>]): kotlin.Unit
public fun test3(/*0*/ x: NL<kotlin.Int> [= NumColl<kotlin.collections.List<out kotlin.Int>>]): kotlin.Unit
public fun test4(/*0*/ x: NL<kotlin.Any> [= NumColl<kotlin.collections.List<out kotlin.Any>>]): kotlin.Unit
public fun test9(/*0*/ x: TC<kotlin.Number, kotlin.collections.Collection<kotlin.Number>> [= TColl<kotlin.Number, kotlin.collections.Collection<kotlin.Number>>]): kotlin.Unit
public final class Num</*0*/ T : kotlin.Number> {
public constructor Num</*0*/ T : kotlin.Number>()
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 NumColl</*0*/ T : kotlin.collections.Collection<kotlin.Number>> {
public constructor NumColl</*0*/ T : kotlin.collections.Collection<kotlin.Number>>()
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 TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<T>> {
public constructor TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<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
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
class TColl<T, C : Collection<T>>
typealias TCErr = TColl<String, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>
typealias TCErr2 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TCErr<!>
fun testType1(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TCErr<!>) {}
val testCtor1 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TCErr()<!>
fun testType2(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TCErr2<!>) {}
val testCtor2 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>TCErr2()<!>
@@ -0,0 +1,15 @@
package
public typealias TCErr = TColl<kotlin.String, kotlin.Any>
public typealias TCErr2 = TCErr
public val testCtor1: TColl<kotlin.String, kotlin.Any>
public val testCtor2: TColl<kotlin.String, kotlin.Any>
public fun testType1(/*0*/ x: TCErr [= TColl<kotlin.String, kotlin.Any>]): kotlin.Unit
public fun testType2(/*0*/ x: TCErr2 [= TColl<kotlin.String, kotlin.Any>]): kotlin.Unit
public final class TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<T>> {
public constructor TColl</*0*/ T, /*1*/ C : kotlin.collections.Collection<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
}