Removed all hack for old inliner + test

Fixes https://github.com/JetBrains/kotlin-native/issues/3275
This commit is contained in:
Igor Chevdar
2019-08-23 14:55:26 +03:00
parent 129f95c0d9
commit 11ecbf7bcd
4 changed files with 32 additions and 7 deletions
@@ -589,7 +589,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
DataFlowIR.Node.NewObject( DataFlowIR.Node.NewObject(
symbolTable.mapFunction(callee), symbolTable.mapFunction(callee),
arguments, arguments,
symbolTable.mapClassReferenceType(callee.constructedClass, false), symbolTable.mapClassReferenceType(callee.constructedClass),
value value
) )
} }
@@ -500,14 +500,11 @@ internal object DataFlowIR {
private fun IrClass.isFinal() = modality == Modality.FINAL private fun IrClass.isFinal() = modality == Modality.FINAL
fun mapClassReferenceType(irClass: IrClass, eraseLocalObjects: Boolean = true): Type { fun mapClassReferenceType(irClass: IrClass): Type {
// Do not try to devirtualize ObjC classes. // Do not try to devirtualize ObjC classes.
if (irClass.module.name == Name.special("<forward declarations>") || irClass.isObjCClass()) if (irClass.module.name == Name.special("<forward declarations>") || irClass.isObjCClass())
return Type.Virtual return Type.Virtual
if (eraseLocalObjects && irClass.isAnonymousObject)
return mapClassReferenceType(irClass.getSuperClassNotAny() ?: context.irBuiltIns.anyClass.owner)
val isFinal = irClass.isFinal() val isFinal = irClass.isFinal()
val isAbstract = irClass.isAbstract() val isAbstract = irClass.isAbstract()
val name = irClass.fqNameForIrSerialization.asString() val name = irClass.fqNameForIrSerialization.asString()
@@ -556,11 +553,11 @@ internal object DataFlowIR {
) )
} }
fun mapType(type: IrType, eraseLocalObjects: Boolean = true): Type { fun mapType(type: IrType): Type {
val binaryType = type.computeBinaryType() val binaryType = type.computeBinaryType()
return when (binaryType) { return when (binaryType) {
is BinaryType.Primitive -> mapPrimitiveBinaryType(binaryType.type) is BinaryType.Primitive -> mapPrimitiveBinaryType(binaryType.type)
is BinaryType.Reference -> mapClassReferenceType(choosePrimary(binaryType.types.toList()), eraseLocalObjects) is BinaryType.Reference -> mapClassReferenceType(choosePrimary(binaryType.types.toList()))
} }
} }
+6
View File
@@ -2396,6 +2396,12 @@ standaloneTest("devirtualization_getter_looking_as_box_function") {
source = "codegen/devirtualization/getter_looking_as_box_function.kt" source = "codegen/devirtualization/getter_looking_as_box_function.kt"
} }
standaloneTest("devirtualization_anonymousObject") {
goldValue = "zzz\n"
flags = ["-opt"]
source = "codegen/devirtualization/anonymousObject.kt"
}
standaloneTest("multiargs") { standaloneTest("multiargs") {
arguments = ["AAA", "BB", "C"] arguments = ["AAA", "BB", "C"]
multiRuns = true multiRuns = true
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
interface I {
fun foo()
}
fun test() {
val impl = object : I {
override fun foo() { println("zzz") }
}
val delegating = object: I by impl { }
delegating.foo()
}
fun main() {
test()
}