K2 KMP: Don't create invalid ConeSubstitutor when type parameters size doesn't match
When type parameters size doesn't match, it's better to pass `null` instead of a parentSubstitutor. Before this commit we were creating an invalid substitutor. Who knows what can go wrong because of that further along the execution Related issue: KT-54827 Related test: compiler/testData/diagnostics/tests/multiplatform/kt54827.kt Review: https://jetbrains.team/p/kt/reviews/12279/files Motivation for the commit: There is no user report or anything. It's not known whether these invalid substitutors were causing problems. I just noticed this problem while doing substitutor API refactoring (see the next commit). Note: `ExpectedActualResolver.matchActualCallableAgainstPotentialExpects` has the same problem. But since it's K1 I won't touch it
This commit is contained in:
+9
-8
@@ -44,15 +44,16 @@ object FirExpectActualResolver {
|
||||
?.fullyExpandedClass(useSiteSession)
|
||||
|
||||
val expectTypeParameters = expectContainingClass?.typeParameterSymbols.orEmpty()
|
||||
val actualTypeParameters = actualContainingClass
|
||||
?.typeParameterSymbols
|
||||
.orEmpty()
|
||||
val actualTypeParameters = actualContainingClass?.typeParameterSymbols.orEmpty()
|
||||
|
||||
parentSubstitutor = createExpectActualTypeParameterSubstitutor(
|
||||
expectTypeParameters,
|
||||
actualTypeParameters,
|
||||
useSiteSession,
|
||||
)
|
||||
parentSubstitutor = when (expectTypeParameters.size == actualTypeParameters.size) {
|
||||
true -> createExpectActualTypeParameterSubstitutor(
|
||||
expectTypeParameters,
|
||||
actualTypeParameters,
|
||||
useSiteSession,
|
||||
)
|
||||
false -> null
|
||||
}
|
||||
|
||||
when (actualSymbol) {
|
||||
is FirConstructorSymbol -> expectContainingClass?.getConstructors(scopeSession)
|
||||
|
||||
Reference in New Issue
Block a user