[Commonizer] Source-based tests on lifting up identical type aliases

^KMM-55
This commit is contained in:
Dmitriy Dolovov
2020-06-01 16:22:17 +07:00
parent e5885e9277
commit d9bfe11ca1
16 changed files with 208 additions and 95 deletions
@@ -9,7 +9,7 @@ expect val propertyWithInferredType3: String
expect val propertyWithInferredType4: Nothing?
expect val propertyWithInferredType5: Planet
expect class C
typealias C = Planet
expect val property1: Int
expect val property2: String
@@ -7,7 +7,6 @@ actual val propertyWithInferredType4 = null
actual val propertyWithInferredType5 = Planet("Earth", 12742)
typealias A = Planet
actual typealias C = Planet
actual val property1 = 1
actual val property2 = "hello"
@@ -7,7 +7,6 @@ actual val propertyWithInferredType4 get() = null
actual val propertyWithInferredType5 get() = Planet("Earth", 12742)
typealias B = Planet
actual typealias C = Planet
actual val property1 = 1
actual val property2 = "hello"
@@ -1,2 +1,25 @@
expect class A ()
expect class B
expect class A()
// Lifted up type aliases:
typealias B = A // class at the RHS
typealias C = B // TA at the RHS
typealias F = List<String> // parameterized type at the RHS
typealias H<T> = List<T> // TA with own parameters
typealias J<T> = Function<T> // function type at the RHS
typealias M = () -> Unit // same return type
typealias O = (String) -> Int // same argument type
typealias Q<T> = (List<M>) -> Map<T, O> // something complex
typealias R = Function<C> // something complex
// Type aliases converted to expect classes:
typealias S = String
expect class T
// Nullability:
typealias U = A // same nullability of the RHS class
expect class V // different nullability of the RHS class
typealias W = U // same nullability of the RHS TA
typealias Y = V // TA at the RHS with the different nullability of own RHS
@@ -1,8 +1,21 @@
actual class A actual constructor()
actual typealias B = A
typealias C = B
typealias D = List<String>
typealias E<T> = List<T>
typealias F<R> = Function<R>
typealias G = () -> Unit
typealias H = (String) -> Int
// Lifted up type aliases:
typealias D = B // class/TA at the RHS
typealias E = C // different TAs at the RHS
typealias G = List<Int> // different parameterized types at the RHS
typealias I<T> = List<T> // TAs with own parameters with different names
typealias K<T> = Function<T> // function types with different type parameter names
typealias L<T> = () -> T // different kinds of function types
typealias N = () -> Any // different return types
typealias P = (Int) -> Int // different argument types
// Type aliases converted to expect classes:
actual typealias T = Int
// Nullability:
actual typealias V = A? // different nullability of the RHS class
typealias X = U? // different nullability of the RHS TA
@@ -1,8 +1,21 @@
actual class A actual constructor()
actual typealias B = A
typealias C = B
typealias D = List<String>
typealias E<T> = List<T>
typealias F<R> = Function<R>
typealias G = () -> Unit
typealias H = (String) -> Int
// Lifted up type aliases:
typealias D = A // class/TA at the RHS
typealias E = B // different TAs at the RHS
typealias G = List<String> // different parameterized types at the RHS
typealias I<R> = List<R> // TAs with own parameters with different names
typealias K<R> = Function<R> // function types with different type parameter names
typealias L<T> = Function<T> // different kinds of function types
typealias N = () -> Unit // different return types
typealias P = (String) -> Int // different argument types
// Type aliases converted to expect classes:
actual typealias T = String
// Nullability:
actual typealias V = A // different nullability of the RHS class
typealias X = U // different nullability of the RHS TA
@@ -1,8 +1,36 @@
class A
typealias B = A
typealias C = B
typealias D = List<String>
typealias E<T> = List<T>
typealias F<R> = Function<R>
typealias G = () -> Unit
typealias H = (String) -> Int
// Lifted up type aliases:
typealias B = A // class at the RHS
typealias C = B // TA at the RHS
typealias D = B // class/TA at the RHS
typealias E = C // different TAs at the RHS
typealias F = List<String> // parameterized type at the RHS
typealias G = List<Int> // different parameterized types at the RHS
typealias H<T> = List<T> // TA with own parameters
typealias I<T> = List<T> // TAs with own parameters with different names
typealias J<T> = Function<T> // function type at the RHS
typealias K<T> = Function<T> // function types with different type parameter names
typealias L<T> = () -> T // different kinds of function types
typealias M = () -> Unit // same return type
typealias N = () -> Any // different return types
typealias O = (String) -> Int // same argument type
typealias P = (Int) -> Int // different argument types
typealias Q<T> = (List<M>) -> Map<T, O> // something complex
typealias R = Function<C> // something complex
// Type aliases converted to expect classes:
typealias S = String
typealias T = Int
// Nullability:
typealias U = A // same nullability of the RHS class
typealias V = A? // different nullability of the RHS class
typealias W = U // same nullability of the RHS TA
typealias X = U? // different nullability of the RHS TA
typealias Y = V // TA at the RHS with the different nullability of own RHS
@@ -1,8 +1,36 @@
class A
typealias B = A
typealias C = B
typealias D = List<String>
typealias E<T> = List<T>
typealias F<R> = Function<R>
typealias G = () -> Unit
typealias H = (String) -> Int
// Lifted up type aliases:
typealias B = A // class at the RHS
typealias C = B // TA at the RHS
typealias D = A // class/TA at the RHS
typealias E = B // different TAs at the RHS
typealias F = List<String> // parameterized type at the RHS
typealias G = List<String> // different parameterized types at the RHS
typealias H<T> = List<T> // TA with own parameters
typealias I<R> = List<R> // TAs with own parameters with different names
typealias J<T> = Function<T> // function type at the RHS
typealias K<R> = Function<R> // function types with different type parameter names
typealias L<T> = Function<T> // different kinds of function types
typealias M = () -> Unit // same return type
typealias N = () -> Unit // different return types
typealias O = (String) -> Int // same argument type
typealias P = (String) -> Int // different argument types
typealias Q<T> = (List<M>) -> Map<T, O> // something complex
typealias R = Function<C> // something complex
// Type aliases converted to expect classes:
typealias S = String
typealias T = String
// Nullability:
typealias U = A // same nullability of the RHS class
typealias V = A // different nullability of the RHS class
typealias W = U // same nullability of the RHS TA
typealias X = U // different nullability of the RHS TA
typealias Y = V // TA at the RHS with the different nullability of own RHS
@@ -1,20 +1,21 @@
expect public class A1()
expect protected class B1()
expect internal class C1()
public expect class A1()
protected expect class B1()
internal expect class C1()
expect public class E1
expect protected class E2
expect internal class E3
expect private class E4
public typealias E1 = A1
protected typealias E2 = A1
internal typealias E3 = A1
public expect class E4
expect protected class F1
expect private class F3
protected typealias F1 = A1
public expect class F2
public expect class F3
expect internal class G1
expect private class G2
internal typealias G1 = A1
public expect class G2
expect private class H1
public expect class H1
expect public class I1
expect public class I2
expect public class I3
public typealias I1 = A1
public typealias I2 = B1
public typealias I3 = C1
@@ -1,32 +1,24 @@
actual public class A1 actual constructor()
public actual class A1 actual constructor()
public class A2
public class A3
public class A4
actual protected class B1 actual constructor()
protected actual class B1 actual constructor()
protected class B2
protected class B3
actual internal class C1 actual constructor()
internal actual class C1 actual constructor()
internal class C2
private class D1
actual public typealias E1 = A1
actual public typealias E2 = A1
actual public typealias E3 = A1
actual public typealias E4 = A1
public actual typealias E4 = A1
actual protected typealias F1 = A1
protected typealias F2 = A1
actual protected typealias F3 = A1
protected actual typealias F2 = A1
protected actual typealias F3 = A1
actual internal typealias G1 = A1
actual internal typealias G2 = A1
internal actual typealias G2 = A1
actual private typealias H1 = A1
private actual typealias H1 = A1
actual public typealias I1 = A1 // points to public
actual public typealias I2 = B1 // points to protected
actual public typealias I3 = C1 // points to internal
public typealias I4 = D1 // points to private
typealias I4 = D1
@@ -1,32 +1,24 @@
actual public class A1 actual constructor()
public actual class A1 actual constructor()
protected class A2
internal class A3
private class A4
actual protected class B1 actual constructor()
protected actual class B1 actual constructor()
internal class B2
private class B3
actual internal class C1 actual constructor()
internal actual class C1 actual constructor()
private class C2
private class D1
actual public typealias E1 = A1
actual protected typealias E2 = A1
actual internal typealias E3 = A1
actual private typealias E4 = A1
private actual typealias E4 = A1
actual protected typealias F1 = A1
internal typealias F2 = A1
actual private typealias F3 = A1
internal actual typealias F2 = A1
private actual typealias F3 = A1
actual internal typealias G1 = A1
actual private typealias G2 = A1
private actual typealias G2 = A1
actual private typealias H1 = A1
private actual typealias H1 = A1
actual public typealias I1 = A1 // points to public
actual public typealias I2 = B1 // points to protected
actual public typealias I3 = C1 // points to internal
public typealias I4 = D1 // points to private
typealias I4 = D1
@@ -13,6 +13,7 @@ expect fun function1(text: String): String
expect fun <Q : Number> Q.function2(): Q
expect class AnnotatedClass(value: String) { val value: String }
expect class AnnotatedTypeAlias
typealias AnnotatedLiftedUpTypeAlias = AnnotatedClass
expect class AnnotatedNonLiftedUpTypeAlias
//expect object ObjectWithNestedAnnotations
@@ -53,9 +53,13 @@ actual fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter")
@CommonAnnotation("class")
actual class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String)
@JsAnnotation("type-alias")
@CommonAnnotation("type-alias")
actual typealias AnnotatedTypeAlias = AnnotatedClass
@JsAnnotation("js-only-class")
@CommonAnnotation("js-only-class")
class JsOnlyAnnotatedClass @JsAnnotation("js-only-constructor") @CommonAnnotation("js-only-constructor") constructor(val value: String)
@JsAnnotation("non-lifted-up-type-alias")
@CommonAnnotation("non-lifted-up-type-alias")
actual typealias AnnotatedNonLiftedUpTypeAlias = JsOnlyAnnotatedClass
//@JsOuterAnnotation(inner = JsInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,13 @@ actual fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter")
@CommonAnnotation("class")
actual class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String)
@JvmAnnotation("type-alias")
@CommonAnnotation("type-alias")
actual typealias AnnotatedTypeAlias = AnnotatedClass
@JvmAnnotation("jvm-only-class")
@CommonAnnotation("jvm-only-class")
class JvmOnlyAnnotatedClass @JvmAnnotation("jvm-only-constructor") @CommonAnnotation("jvm-only-constructor") constructor(val value: String)
@JvmAnnotation("non-lifted-up-type-alias")
@CommonAnnotation("non-lifted-up-type-alias")
actual typealias AnnotatedNonLiftedUpTypeAlias = JvmOnlyAnnotatedClass
//@JvmOuterAnnotation(inner = JvmInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,17 @@ fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @Js
@CommonAnnotation("class")
class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String)
@JsAnnotation("type-alias")
@CommonAnnotation("type-alias")
typealias AnnotatedTypeAlias = AnnotatedClass
@JsAnnotation("js-only-class")
@CommonAnnotation("js-only-class")
class JsOnlyAnnotatedClass @JsAnnotation("js-only-constructor") @CommonAnnotation("js-only-constructor") constructor(val value: String)
@JsAnnotation("lifted-up-type-alias")
@CommonAnnotation("lifted-up-type-alias")
typealias AnnotatedLiftedUpTypeAlias = AnnotatedClass
@JsAnnotation("non-lifted-up-type-alias")
@CommonAnnotation("non-lifted-up-type-alias")
typealias AnnotatedNonLiftedUpTypeAlias = JsOnlyAnnotatedClass
//@JsOuterAnnotation(inner = JsInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,17 @@ fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @J
@CommonAnnotation("class")
class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String)
@JvmAnnotation("type-alias")
@CommonAnnotation("type-alias")
typealias AnnotatedTypeAlias = AnnotatedClass
@JvmAnnotation("jvm-only-class")
@CommonAnnotation("jvm-only-class")
class JvmOnlyAnnotatedClass @JvmAnnotation("jvm-only-constructor") @CommonAnnotation("jvm-only-constructor") constructor(val value: String)
@JvmAnnotation("lifted-up-type-alias")
@CommonAnnotation("lifted-up-type-alias")
typealias AnnotatedLiftedUpTypeAlias = AnnotatedClass
@JvmAnnotation("non-lifted-up-type-alias")
@CommonAnnotation("non-lifted-up-type-alias")
typealias AnnotatedNonLiftedUpTypeAlias = JvmOnlyAnnotatedClass
//@JvmOuterAnnotation(inner = JvmInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))