873224dfbc
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
FIR Analysis tests
Mostly, format of FIR analysis test is the same as the one described at compiler/testData/diagnostics/ReadMe.md.
DEBUG_INFO_EXPRESSION_TYPE and DEBUG_INFO_CALL are also partially supported but need to be written out explicitly in a test data file:
fun foo(
x1: String,
x2: Collection<CharSequence>,
x3: MutableMap<out CharSequence, in MutableList<*>>
) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>x1<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.Collection<kotlin.CharSequence>")!>x2<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.MutableMap<out kotlin.CharSequence, in kotlin.collections.MutableList<*>>")!>x3<!>
}
interface B {
operator fun invoke(x: Int): String
}
class A {
fun foo(x: Int) {
fun baz(x: Double) {}
<!DEBUG_INFO_CALL("fqName: A.foo.baz; typeCall: function")!>baz(1.0)<!>
}
val bar: B = TODO()
}
fun A.foo(x: String) {}
fun main() {
fun A.foo(x: Double) {}
val a = A()
a.<!DEBUG_INFO_CALL("fqName: A.foo; typeCall: function")!>foo(1)<!>
a.<!DEBUG_INFO_CALL("fqName: foo; typeCall: extension function")!>foo("")<!>
a.<!DEBUG_INFO_CALL("fqName: main.foo; typeCall: extension function")!>foo(1.0)<!>
a.<!DEBUG_INFO_CALL("fqName: B.invoke; typeCall: variable&invoke")!>bar(1)<!>
}
Specific Directives
// FIR_IDENTICALshould be prepended in a.ktfile of an old diagnostic test when analysis result of old FE and FIR are the same// FIR_IGNOREshould be prepended in a.fir.ktfile of an old diagnostic test known to fail with exception// !DUMP_CFGgenerates.dotfile with rendered data flow graph (see comment atorg.jetbrains.kotlin.fir.AbstractFirDiagnosticsTest)