Fir2Ir scripts: fix declarations registration and processing

This commit is contained in:
Ilya Chernikov
2023-04-27 17:53:33 +02:00
committed by Space Team
parent 5824b9c59c
commit 9adf24950a
12 changed files with 23 additions and 40 deletions
@@ -217,7 +217,8 @@ class Fir2IrConverter(
internal fun processRegularClassMembers(
regularClass: FirRegularClass,
irClass: IrClass = classifierStorage.getCachedIrClass(regularClass)!!
irClass: IrClass =
classifierStorage.getCachedIrClass(regularClass) ?: error("Expecting existing IrClass for class ${regularClass.name}")
): IrClass {
val allDeclarations = mutableListOf<FirDeclaration>().apply {
addAll(regularClass.declarations)
@@ -361,6 +362,16 @@ class Fir2IrConverter(
assert(parent is IrFile)
declarationStorage.getOrCreateIrScript(declaration).also { irScript ->
declarationStorage.enterScope(irScript)
irScript.parent = parent
for (scriptStatement in declaration.statements) {
if (scriptStatement is FirDeclaration) {
if (scriptStatement is FirRegularClass) {
registerClassAndNestedClasses(scriptStatement, irScript)
processClassAndNestedClassHeaders(scriptStatement)
}
}
}
for (scriptStatement in declaration.statements) {
if (scriptStatement is FirDeclaration) {
processMemberDeclaration(scriptStatement, null, irScript)
@@ -184,6 +184,7 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli
override fun visitScript(script: FirScript, data: FirRecorderData) {
val symbol = script.symbol
data.state.scriptContainerMap[symbol] = data.file
script.acceptChildren(this, data)
}
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
import kotlin.reflect.KProperty
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
class SimpleClass(val s: String) {
fun foo() = s
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
import kotlin.reflect.KProperty
@@ -17,9 +17,9 @@ class Nested {
val innerThisProp = this<!UNRESOLVED_LABEL!>@NestedInnerClass<!>.property
inner class InnerInner {
fun f() = <!UNRESOLVED_REFERENCE!>innerFun<!>()
fun g() = <!UNRESOLVED_REFERENCE!>innerProp<!>
fun h() = this@Inner.<!UNRESOLVED_REFERENCE!>innerFun<!>()
fun i() = this@Inner.<!UNRESOLVED_REFERENCE!>innerProp<!>
fun f() = innerFun()
fun g() = innerProp
fun h() = this@Inner.innerFun()
fun i() = this@Inner.innerProp
}
}
@@ -1,11 +1,11 @@
// !WITH_NEW_INFERENCE
val (a1, a2) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>A()<!>
val (b1: Int, b2: Int) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>A()<!>
val (a1, a2) = A()
val (b1: Int, b2: Int) = A()
val (c1) = <!COMPONENT_FUNCTION_MISSING, UNRESOLVED_REFERENCE!>unresolved<!>
<!WRONG_MODIFIER_TARGET!>private<!> val (d1) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
<!WRONG_MODIFIER_TARGET!>private<!> val (d1) = A()
val (e1, _) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
val (e1, _) = A()
<!UNRESOLVED_REFERENCE!>a1<!>
<!UNRESOLVED_REFERENCE!>a2<!>
@@ -1,7 +0,0 @@
val (a, b, c) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING!>A<!NO_VALUE_FOR_PARAMETER!>()<!><!>
class A(val a: Int) {
operator fun component1() {}
operator fun component2() {}
operator fun component3() {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
val (a, b, c) = A<!NO_VALUE_FOR_PARAMETER!>()<!>
class A(val a: Int) {
@@ -1,20 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
import kotlin.reflect.KProperty
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int {
return 1
}
}
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
class Foo {
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
}
fun foo() {
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>Delegate()<!>
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
import kotlin.reflect.KProperty