[JS IR BE] New Inliner from native
This commit is contained in:
+5
-10
@@ -37,7 +37,6 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.NameUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parents
|
||||
import java.util.*
|
||||
|
||||
interface LocalNameProvider {
|
||||
@@ -73,13 +72,9 @@ class LocalDeclarationsLowering(
|
||||
|
||||
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
|
||||
if (irDeclarationContainer is IrDeclaration) {
|
||||
val parents = irDeclarationContainer.parents
|
||||
|
||||
// TODO: in case of `crossinline` lambda the @containingDeclaration and @parent points to completely different locations
|
||||
// val parentsDecl = irDeclarationContainer.parents
|
||||
val parentsDesc = irDeclarationContainer.descriptor.parents
|
||||
|
||||
if (parentsDesc.any { it is CallableDescriptor }) {
|
||||
|
||||
if (parents.any { it is IrFunction || it is IrField }) {
|
||||
// Lowering of non-local declarations handles all local declarations inside.
|
||||
// This declaration is local and shouldn't be considered.
|
||||
return
|
||||
@@ -180,9 +175,9 @@ class LocalDeclarationsLowering(
|
||||
val oldParameterToNew: MutableMap<IrValueParameter, IrValueParameter> = mutableMapOf()
|
||||
val newParameterToCaptured: MutableMap<IrValueParameter, IrValueSymbol> = mutableMapOf()
|
||||
|
||||
fun lowerLocalDeclarations(): List<IrDeclaration>? {
|
||||
fun lowerLocalDeclarations(): List<IrDeclaration> {
|
||||
collectLocalDeclarations()
|
||||
if (localFunctions.isEmpty() && localClasses.isEmpty()) return null
|
||||
if (localFunctions.isEmpty() && localClasses.isEmpty()) return listOf(memberDeclaration)
|
||||
|
||||
collectClosures()
|
||||
|
||||
@@ -778,4 +773,4 @@ class LocalDeclarationsLowering(
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -208,9 +208,10 @@ fun IrConstructor.callsSuper(irBuiltIns: IrBuiltIns): Boolean {
|
||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall) {
|
||||
assert(++numberOfCalls == 1) { "More than one delegating constructor call: ${symbol.owner}" }
|
||||
val delegatingClass = expression.symbol.owner.parent as IrClass
|
||||
if (delegatingClass == superClass.classifierOrFail.owner)
|
||||
// TODO: figure out why Lazy IR multiplies Declarations for descriptors and fix it
|
||||
if (delegatingClass.descriptor == superClass.classifierOrFail.descriptor)
|
||||
callsSuper = true
|
||||
else if (delegatingClass != constructedClass)
|
||||
else if (delegatingClass.descriptor != constructedClass.descriptor)
|
||||
throw AssertionError(
|
||||
"Expected either call to another constructor of the class being constructed or" +
|
||||
" call to super class constructor. But was: $delegatingClass"
|
||||
|
||||
Reference in New Issue
Block a user