0ef1628751
Before this change: - Local scopes, implicit receivers and type parameter scopes were separated. - Static scopes for super classes were not present as a concept. Instead of them, all-inherited-static for the current class has been used. - During call resolution we were processing implicit receivers first and then non-local scopes, while we should process them in the order of their syntax appearance from the closest to the most distant All these facts affect semantics (see test data changed here and the following commits) The architecture changes are the following: - FirTowerDataElement introduced as tower level that is used in resolution (effectively it's a union type between scope and implicit receiver + isLocal flag) - FirTowerDataContext introduced for sake of encapsulation of tower data elements' list (it also has redundant implicitReceiverStack and localScopes) - For each regular class we collect relevant tower data elements and add them to the current context - Also, we preserve a special tower data context for static entities of the class (it doesn't have class' dispatch receiver and generic parameters)
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)