[Commonizer] Relax conditions for TA lifting-up
Allow lifting up matching TAs with non-empty list of type parameters and non-empty list of type arguments in the expanded type.
This commit is contained in:
+3
-3
@@ -45,6 +45,7 @@ class TypeAliasCommonizer(cache: CirClassifiersCache) : AbstractStandardCommoniz
|
|||||||
|
|
||||||
private class TypeAliasShortCircuitingCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirTypeAlias, CirTypeAlias>() {
|
private class TypeAliasShortCircuitingCommonizer(cache: CirClassifiersCache) : AbstractStandardCommonizer<CirTypeAlias, CirTypeAlias>() {
|
||||||
private lateinit var name: Name
|
private lateinit var name: Name
|
||||||
|
private val typeParameters = TypeParameterListCommonizer(cache)
|
||||||
private val expandedType = TypeCommonizer(cache)
|
private val expandedType = TypeCommonizer(cache)
|
||||||
private val visibility = VisibilityCommonizer.lowering()
|
private val visibility = VisibilityCommonizer.lowering()
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ private class TypeAliasShortCircuitingCommonizer(cache: CirClassifiersCache) : A
|
|||||||
return CirTypeAliasFactory.create(
|
return CirTypeAliasFactory.create(
|
||||||
annotations = emptyList(),
|
annotations = emptyList(),
|
||||||
name = name,
|
name = name,
|
||||||
typeParameters = emptyList(),
|
typeParameters = typeParameters.result,
|
||||||
visibility = visibility.result,
|
visibility = visibility.result,
|
||||||
underlyingType = expandedType, // pass expanded type as underlying type
|
underlyingType = expandedType, // pass expanded type as underlying type
|
||||||
expandedType = expandedType
|
expandedType = expandedType
|
||||||
@@ -69,8 +70,7 @@ private class TypeAliasShortCircuitingCommonizer(cache: CirClassifiersCache) : A
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun doCommonizeWith(next: CirTypeAlias) =
|
override fun doCommonizeWith(next: CirTypeAlias) =
|
||||||
next.typeParameters.isEmpty() // short-circuiting of TAs with type parameters is too complex case, consider implementing it later
|
typeParameters.commonizeWith(next.typeParameters)
|
||||||
&& next.expandedType.arguments.isEmpty() // short-circuiting of TAs with type arguments in expanded type is too complex case
|
|
||||||
&& expandedType.commonizeWith(next.expandedType)
|
&& expandedType.commonizeWith(next.expandedType)
|
||||||
&& visibility.commonizeWith(next)
|
&& visibility.commonizeWith(next)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+11
@@ -12,6 +12,17 @@ typealias E = A // different TAs expanded to the same class at the RHS
|
|||||||
typealias F = List<String> // parameterized type at the RHS
|
typealias F = List<String> // parameterized type at the RHS
|
||||||
typealias H<T> = List<T> // TA with own parameters
|
typealias H<T> = List<T> // TA with own parameters
|
||||||
|
|
||||||
|
typealias I2<T> = List<T>
|
||||||
|
typealias I3<R> = List<R>
|
||||||
|
typealias I4 = List<String>
|
||||||
|
|
||||||
|
typealias I5<V, K> = Map<K, V>
|
||||||
|
typealias I6<T, R> = Map<R, T>
|
||||||
|
|
||||||
|
typealias I7<K, V> = Map<K, V>
|
||||||
|
typealias I8<T, R> = Map<R, T>
|
||||||
|
typealias I9<Q, W> = Map<W, Q>
|
||||||
|
|
||||||
typealias J<T> = Function<T> // function type at the RHS
|
typealias J<T> = Function<T> // function type at the RHS
|
||||||
typealias M = () -> Unit // same return type
|
typealias M = () -> Unit // same return type
|
||||||
typealias O = (String) -> Int // same argument type
|
typealias O = (String) -> Int // same argument type
|
||||||
|
|||||||
Vendored
+11
@@ -15,6 +15,17 @@ typealias G = List<Int> // different parameterized types at the RHS
|
|||||||
typealias H<T> = List<T> // TA with own parameters
|
typealias H<T> = List<T> // TA with own parameters
|
||||||
typealias I<T> = List<T> // TAs with own parameters with different names
|
typealias I<T> = List<T> // TAs with own parameters with different names
|
||||||
|
|
||||||
|
typealias I2<T> = List<T>
|
||||||
|
typealias I3<R> = I2<R>
|
||||||
|
typealias I4 = I2<String>
|
||||||
|
|
||||||
|
typealias I5<V, K> = Map<K, V>
|
||||||
|
typealias I6<T, R> = I5<T, R>
|
||||||
|
|
||||||
|
typealias I7<K, V> = Map<K, V>
|
||||||
|
typealias I8<T, R> = I7<R, T>
|
||||||
|
typealias I9<Q, W> = I8<Q, W>
|
||||||
|
|
||||||
typealias J<T> = Function<T> // function type at the RHS
|
typealias J<T> = Function<T> // function type at the RHS
|
||||||
typealias K<T> = Function<T> // function types with different type parameter names
|
typealias K<T> = Function<T> // function types with different type parameter names
|
||||||
typealias L<T> = () -> T // different kinds of function types
|
typealias L<T> = () -> T // different kinds of function types
|
||||||
|
|||||||
Vendored
+11
@@ -15,6 +15,17 @@ typealias G = List<String> // different parameterized types at the RHS
|
|||||||
typealias H<T> = List<T> // TA with own parameters
|
typealias H<T> = List<T> // TA with own parameters
|
||||||
typealias I<R> = List<R> // TAs with own parameters with different names
|
typealias I<R> = List<R> // TAs with own parameters with different names
|
||||||
|
|
||||||
|
typealias I2<T> = List<T>
|
||||||
|
typealias I3<R> = I2<R>
|
||||||
|
typealias I4 = I2<String>
|
||||||
|
|
||||||
|
typealias I5<V, K> = Map<K, V>
|
||||||
|
typealias I6<T, R> = I5<T, R>
|
||||||
|
|
||||||
|
typealias I7<K, V> = Map<K, V>
|
||||||
|
typealias I8<T, R> = I7<R, T>
|
||||||
|
typealias I9<Q, W> = I8<Q, W>
|
||||||
|
|
||||||
typealias J<T> = Function<T> // function type at the RHS
|
typealias J<T> = Function<T> // function type at the RHS
|
||||||
typealias K<R> = Function<R> // function types with different type parameter names
|
typealias K<R> = Function<R> // function types with different type parameter names
|
||||||
typealias L<T> = Function<T> // different kinds of function types
|
typealias L<T> = Function<T> // different kinds of function types
|
||||||
|
|||||||
Reference in New Issue
Block a user