[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 propertyWithInferredType4: Nothing?
expect val propertyWithInferredType5: Planet expect val propertyWithInferredType5: Planet
expect class C typealias C = Planet
expect val property1: Int expect val property1: Int
expect val property2: String expect val property2: String
@@ -7,7 +7,6 @@ actual val propertyWithInferredType4 = null
actual val propertyWithInferredType5 = Planet("Earth", 12742) actual val propertyWithInferredType5 = Planet("Earth", 12742)
typealias A = Planet typealias A = Planet
actual typealias C = Planet
actual val property1 = 1 actual val property1 = 1
actual val property2 = "hello" actual val property2 = "hello"
@@ -7,7 +7,6 @@ actual val propertyWithInferredType4 get() = null
actual val propertyWithInferredType5 get() = Planet("Earth", 12742) actual val propertyWithInferredType5 get() = Planet("Earth", 12742)
typealias B = Planet typealias B = Planet
actual typealias C = Planet
actual val property1 = 1 actual val property1 = 1
actual val property2 = "hello" actual val property2 = "hello"
@@ -1,2 +1,25 @@
expect class A () expect class A()
expect class B
// 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 class A actual constructor()
actual typealias B = A
typealias C = B // Lifted up type aliases:
typealias D = List<String> typealias D = B // class/TA at the RHS
typealias E<T> = List<T> typealias E = C // different TAs at the RHS
typealias F<R> = Function<R>
typealias G = () -> Unit typealias G = List<Int> // different parameterized types at the RHS
typealias H = (String) -> Int
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 class A actual constructor()
actual typealias B = A
typealias C = B // Lifted up type aliases:
typealias D = List<String> typealias D = A // class/TA at the RHS
typealias E<T> = List<T> typealias E = B // different TAs at the RHS
typealias F<R> = Function<R>
typealias G = () -> Unit typealias G = List<String> // different parameterized types at the RHS
typealias H = (String) -> Int
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 class A
typealias B = A
typealias C = B // Lifted up type aliases:
typealias D = List<String> typealias B = A // class at the RHS
typealias E<T> = List<T> typealias C = B // TA at the RHS
typealias F<R> = Function<R>
typealias G = () -> Unit typealias D = B // class/TA at the RHS
typealias H = (String) -> Int 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 class A
typealias B = A
typealias C = B // Lifted up type aliases:
typealias D = List<String> typealias B = A // class at the RHS
typealias E<T> = List<T> typealias C = B // TA at the RHS
typealias F<R> = Function<R>
typealias G = () -> Unit typealias D = A // class/TA at the RHS
typealias H = (String) -> Int 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() public expect class A1()
expect protected class B1() protected expect class B1()
expect internal class C1() internal expect class C1()
expect public class E1 public typealias E1 = A1
expect protected class E2 protected typealias E2 = A1
expect internal class E3 internal typealias E3 = A1
expect private class E4 public expect class E4
expect protected class F1 protected typealias F1 = A1
expect private class F3 public expect class F2
public expect class F3
expect internal class G1 internal typealias G1 = A1
expect private class G2 public expect class G2
expect private class H1 public expect class H1
expect public class I1 public typealias I1 = A1
expect public class I2 public typealias I2 = B1
expect public class I3 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 A2
public class A3 public class A3
public class A4 public class A4
actual protected class B1 actual constructor() protected actual class B1 actual constructor()
protected class B2 protected class B2
protected class B3 protected class B3
actual internal class C1 actual constructor() internal actual class C1 actual constructor()
internal class C2 internal class C2
private class D1 private class D1
actual public typealias E1 = A1 public actual typealias E4 = A1
actual public typealias E2 = A1
actual public typealias E3 = A1
actual public typealias E4 = A1
actual protected typealias F1 = A1 protected actual typealias F2 = A1
protected typealias F2 = A1 protected actual typealias F3 = A1
actual protected typealias F3 = A1
actual internal typealias G1 = A1 internal actual typealias G2 = A1
actual internal typealias G2 = A1
actual private typealias H1 = A1 private actual typealias H1 = A1
actual public typealias I1 = A1 // points to public typealias I4 = D1
actual public typealias I2 = B1 // points to protected
actual public typealias I3 = C1 // points to internal
public typealias I4 = D1 // points to private
@@ -1,32 +1,24 @@
actual public class A1 actual constructor() public actual class A1 actual constructor()
protected class A2 protected class A2
internal class A3 internal class A3
private class A4 private class A4
actual protected class B1 actual constructor() protected actual class B1 actual constructor()
internal class B2 internal class B2
private class B3 private class B3
actual internal class C1 actual constructor() internal actual class C1 actual constructor()
private class C2 private class C2
private class D1 private class D1
actual public typealias E1 = A1 private actual typealias E4 = A1
actual protected typealias E2 = A1
actual internal typealias E3 = A1
actual private typealias E4 = A1
actual protected typealias F1 = A1 internal actual typealias F2 = A1
internal typealias F2 = A1 private actual typealias F3 = A1
actual private typealias F3 = A1
actual internal typealias G1 = A1 private actual typealias G2 = A1
actual private typealias G2 = A1
actual private typealias H1 = A1 private actual typealias H1 = A1
actual public typealias I1 = A1 // points to public typealias I4 = D1
actual public typealias I2 = B1 // points to protected
actual public typealias I3 = C1 // points to internal
public typealias I4 = D1 // points to private
@@ -13,6 +13,7 @@ expect fun function1(text: String): String
expect fun <Q : Number> Q.function2(): Q expect fun <Q : Number> Q.function2(): Q
expect class AnnotatedClass(value: String) { val value: String } expect class AnnotatedClass(value: String) { val value: String }
expect class AnnotatedTypeAlias typealias AnnotatedLiftedUpTypeAlias = AnnotatedClass
expect class AnnotatedNonLiftedUpTypeAlias
//expect object ObjectWithNestedAnnotations //expect object ObjectWithNestedAnnotations
@@ -53,9 +53,13 @@ actual fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter")
@CommonAnnotation("class") @CommonAnnotation("class")
actual class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String) actual class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String)
@JsAnnotation("type-alias") @JsAnnotation("js-only-class")
@CommonAnnotation("type-alias") @CommonAnnotation("js-only-class")
actual typealias AnnotatedTypeAlias = AnnotatedClass 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")) //@JsOuterAnnotation(inner = JsInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations")) //@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,13 @@ actual fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter")
@CommonAnnotation("class") @CommonAnnotation("class")
actual class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String) actual class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") actual constructor(actual val value: String)
@JvmAnnotation("type-alias") @JvmAnnotation("jvm-only-class")
@CommonAnnotation("type-alias") @CommonAnnotation("jvm-only-class")
actual typealias AnnotatedTypeAlias = AnnotatedClass 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")) //@JvmOuterAnnotation(inner = JvmInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations")) //@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,17 @@ fun <@JsAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @Js
@CommonAnnotation("class") @CommonAnnotation("class")
class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String) class AnnotatedClass @JsAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String)
@JsAnnotation("type-alias") @JsAnnotation("js-only-class")
@CommonAnnotation("type-alias") @CommonAnnotation("js-only-class")
typealias AnnotatedTypeAlias = AnnotatedClass 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")) //@JsOuterAnnotation(inner = JsInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations")) //@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))
@@ -53,9 +53,17 @@ fun <@JvmAnnotation("type-parameter") @CommonAnnotation("type-parameter") Q : @J
@CommonAnnotation("class") @CommonAnnotation("class")
class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String) class AnnotatedClass @JvmAnnotation("constructor") @CommonAnnotation("constructor") constructor(val value: String)
@JvmAnnotation("type-alias") @JvmAnnotation("jvm-only-class")
@CommonAnnotation("type-alias") @CommonAnnotation("jvm-only-class")
typealias AnnotatedTypeAlias = AnnotatedClass 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")) //@JvmOuterAnnotation(inner = JvmInnerAnnotation("nested-annotations"))
//@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations")) //@CommonOuterAnnotation(inner = CommonInnerAnnotation("nested-annotations"))