Fixed bug in vTable building + test

This commit is contained in:
Igor Chevdar
2018-04-18 18:24:41 +03:00
parent 388ee82e9d
commit 9e0c44a323
5 changed files with 28 additions and 1 deletions
@@ -89,7 +89,7 @@ internal class SpecialDeclarationsFactory(val context: Context) {
val irFunction = overriddenFunctionDescriptor.descriptor
val descriptor = irFunction.descriptor
assert(overriddenFunctionDescriptor.needBridge,
{ "Function $descriptor is not needed in a bridge to call overridden function ${overriddenFunctionDescriptor.overriddenDescriptor}" })
{ "Function $descriptor is not needed in a bridge to call overridden function ${overriddenFunctionDescriptor.overriddenDescriptor.descriptor}" })
val bridgeDirections = overriddenFunctionDescriptor.bridgeDirections
return bridgesDescriptors.getOrPut(irFunction to bridgeDirections) {
val newDescriptor = SimpleFunctionDescriptorImpl.create(
@@ -186,4 +186,6 @@ private val IrClass.sortedOverridableOrOverridingMethods: List<SimpleFunctionDes
get() =
this.simpleFunctions()
.filter { it.isOverridable || it.overriddenSymbols.isNotEmpty() }
// TODO: extract method .isBridge()
.filterNot { it.name.asString().contains("<bridge-") }
.sortedBy { it.functionName.localHash.value }
+6
View File
@@ -958,6 +958,12 @@ task bridges_linkTest(type: LinkKonanTest) {
lib = "codegen/bridges/linkTest_lib.kt"
}
task bridges_linkTest2(type: LinkKonanTest) {
goldValue = "true\n"
source = "codegen/bridges/linkTest2_main.kt"
lib = "codegen/bridges/linkTest2_lib.kt"
}
task bridges_special(type: RunKonanTest) {
goldValue = "Ok\n"
source = "codegen/bridges/special.kt"
@@ -0,0 +1,15 @@
sealed class Tag {
abstract fun value(): Any
}
sealed class TagBoolean : Tag() {
abstract override fun value(): Boolean
object True : TagBoolean() {
override fun value() = true
}
object False : TagBoolean() {
override fun value() = false
}
}
@@ -0,0 +1,4 @@
fun main(args: Array<String>) {
val test: TagBoolean = TagBoolean.True
println(test.value())
}