[NI] Use new type substitutor for known type parameters

Use known type parameters substitutor after substitutor for fresh variables.
The old logic of substituions had the following order:
- replace known type parameters
- replace type parameters with type variables
- complete inference
- replace type variables with inferred types

According to the updated logic, replacement goes as follows:
- replace type parameters with type variables
- replace known type parameters; if they were variables, this will effectively remove them from inference
- complete inference
- replace remaining type variables with inferred types

Support projection substitution in new type substitutor.
It is needed for correct interaction with old type substitutor.
Old type substitutors can contain mappings constructor -> projection
which couldn't be expressed correctly with existing substitutor API in some cases.

^KT-41386 Fixed
This commit is contained in:
Pavel Kirpichenkov
2020-08-29 18:10:41 +03:00
parent c706673de9
commit 873224dfbc
13 changed files with 129 additions and 29 deletions
@@ -0,0 +1,8 @@
// !LANGUAGE: +NewInference
open class Test<T1, T2>(val map1 : Map<T1, T2>, val map2 : Map<T2, T1>) {
open val inverse: Test<T2, T1> = object : <!INAPPLICABLE_CANDIDATE!>Test<T2, T1><!>(map2, map1) {
override val inverse: Test<T1, T2>
get() = this@Test
}
}
@@ -0,0 +1,8 @@
// !LANGUAGE: +NewInference
open class Test<T1, T2>(val map1 : Map<T1, T2>, val map2 : Map<T2, T1>) {
open val inverse: Test<T2, T1> = object : Test<T2, T1>(map2, map1) {
override val inverse: Test<T1, T2>
get() = this@Test
}
}
@@ -0,0 +1,11 @@
package
public open class Test</*0*/ T1, /*1*/ T2> {
public constructor Test</*0*/ T1, /*1*/ T2>(/*0*/ map1: kotlin.collections.Map<T1, T2>, /*1*/ map2: kotlin.collections.Map<T2, T1>)
public open val inverse: Test<T2, T1>
public final val map1: kotlin.collections.Map<T1, T2>
public final val map2: kotlin.collections.Map<T2, T1>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}