Refactoring: Improve createExpectActualTypeParameterSubstitutor API
Review: https://jetbrains.team/p/kt/reviews/12279/files Motivation: make sure that cases like KT-62027 won't happen again Review: https://jetbrains.team/p/kt/reviews/12279/files Now it's responsibility of the `createExpectActualTypeParameterSubstitutor` calller to think about the case when parameters size isn't equal. You must not be able to create a substitutor if type parameters sizes are not equal Improvement in `createExpectActualTypeParameterSubstitutor` API also improves `AbstractExpectActualCompatibilityChecker.getCallablesCompatibility` API. Because suppose that you accidentally created a redundant wrapping substitutor => you need to handle the case of not equal type parameters size on the call site => you start thinking why you should do that on the call site? It must be a responsibility of `getCallablesCompatibility` => you realize that you created a redundant wrapping substitutor
This commit is contained in:
+5
-4
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.enumMapOf
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.enumSetOf
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
import org.jetbrains.kotlin.utils.zipIfSizesAreEqual
|
||||
import java.util.*
|
||||
|
||||
object AbstractExpectActualCompatibilityChecker {
|
||||
@@ -124,8 +125,8 @@ object AbstractExpectActualCompatibilityChecker {
|
||||
}
|
||||
|
||||
val substitutor = createExpectActualTypeParameterSubstitutor(
|
||||
expectTypeParameterSymbols,
|
||||
actualTypeParameterSymbols,
|
||||
(expectTypeParameterSymbols zipIfSizesAreEqual actualTypeParameterSymbols)
|
||||
?: error("expect/actual type parameters sizes are checked above"),
|
||||
parentSubstitutor
|
||||
)
|
||||
|
||||
@@ -348,8 +349,8 @@ object AbstractExpectActualCompatibilityChecker {
|
||||
}
|
||||
|
||||
val substitutor = createExpectActualTypeParameterSubstitutor(
|
||||
expectedTypeParameters,
|
||||
actualTypeParameters,
|
||||
(expectedTypeParameters zipIfSizesAreEqual actualTypeParameters)
|
||||
?: error("expect/actual type parameters sizes are checked above"),
|
||||
parentSubstitutor
|
||||
)
|
||||
|
||||
|
||||
+1
-2
@@ -103,8 +103,7 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
|
||||
val PropertySymbolMarker.setter: FunctionSymbolMarker?
|
||||
|
||||
fun createExpectActualTypeParameterSubstitutor(
|
||||
expectTypeParameters: List<TypeParameterSymbolMarker>,
|
||||
actualTypeParameters: List<TypeParameterSymbolMarker>,
|
||||
expectActualTypeParameters: List<Pair<TypeParameterSymbolMarker, TypeParameterSymbolMarker>>,
|
||||
parentSubstitutor: TypeSubstitutorMarker?
|
||||
): TypeSubstitutorMarker
|
||||
|
||||
|
||||
Reference in New Issue
Block a user