K/N counterpart for private fake overrides construction on klib load
(cherry picked from commit 7f51998848204f2ca8e4f94100f942d9b3d4cf14)
This commit is contained in:
committed by
Vasily Levchenko
parent
1bdd07d24d
commit
38fbb7480a
+1
-1
@@ -29,5 +29,5 @@ class KonanIrFileSerializer(
|
||||
return node.annotations.hasAnnotation(fqn)
|
||||
}
|
||||
|
||||
override fun backendSpecificSerializeAllMembers(irClass: IrClass) = !KonanFakeOverrideClassFilter.constructFakeOverrides(irClass)
|
||||
override fun backendSpecificSerializeAllMembers(irClass: IrClass) = !KonanFakeOverrideClassFilter.needToConstructFakeOverrides(irClass)
|
||||
}
|
||||
+4
-5
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.backend.konan.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder
|
||||
import org.jetbrains.kotlin.backend.common.overrides.PlatformFakeOverrideClassFilter
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideClassFilter
|
||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
@@ -48,7 +48,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
object KonanFakeOverrideClassFilter : PlatformFakeOverrideClassFilter {
|
||||
object KonanFakeOverrideClassFilter : FakeOverrideClassFilter {
|
||||
private fun IdSignature.isInteropSignature(): Boolean = with(this) {
|
||||
IdSignature.Flags.IS_NATIVE_INTEROP_LIBRARY.test()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ object KonanFakeOverrideClassFilter : PlatformFakeOverrideClassFilter {
|
||||
.filter { it is IrPublicSymbolBase<*> }
|
||||
.any { it.signature.isInteropSignature() }
|
||||
|
||||
override fun constructFakeOverrides(clazz: IrClass): Boolean {
|
||||
override fun needToConstructFakeOverrides(clazz: IrClass): Boolean {
|
||||
return !clazz.hasInteropSuperClass()
|
||||
}
|
||||
}
|
||||
@@ -91,9 +91,8 @@ internal class KonanIrLinker(
|
||||
|
||||
override fun isBuiltInModule(moduleDescriptor: ModuleDescriptor): Boolean = moduleDescriptor.isNativeStdlib()
|
||||
|
||||
override val fakeOverrideBuilder = FakeOverrideBuilder(symbolTable, IdSignatureSerializer(KonanManglerIr), builtIns, KonanFakeOverrideClassFilter)
|
||||
|
||||
private val forwardDeclarationDeserializer = forwardModuleDescriptor?.let { KonanForwardDeclarationModuleDeserializer(it) }
|
||||
override val fakeOverrideBuilder = FakeOverrideBuilder(this, symbolTable, IdSignatureSerializer(KonanManglerIr), builtIns, KonanFakeOverrideClassFilter)
|
||||
|
||||
override fun createModuleDeserializer(moduleDescriptor: ModuleDescriptor, klib: IrLibrary?, strategy: DeserializationStrategy): IrModuleDeserializer {
|
||||
if (moduleDescriptor === forwardModuleDescriptor) {
|
||||
|
||||
@@ -4395,6 +4395,18 @@ standaloneTest("fake_override_0") {
|
||||
goldValue = "Moved\nMoved\nChild\nSuper\n"
|
||||
}
|
||||
|
||||
linkTest("private_fake_overrides_0") {
|
||||
source = "link/private_fake_overrides/inherit_main.kt"
|
||||
lib = "link/private_fake_overrides/inherit_lib.kt"
|
||||
goldValue = "PASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\n"
|
||||
}
|
||||
|
||||
linkTest("private_fake_overrides_1") {
|
||||
source = "link/private_fake_overrides/override_main.kt"
|
||||
lib = "link/private_fake_overrides/override_lib.kt"
|
||||
goldValue = "PASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\nPASS\n"
|
||||
}
|
||||
|
||||
Task frameworkTest(String name, Closure<FrameworkTest> configurator) {
|
||||
return KotlinNativeTestKt.createTest(project, name, FrameworkTest) { task ->
|
||||
configurator.delegate = task
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
// Private classes
|
||||
private open class A {
|
||||
public fun foo1() = println("PASS")
|
||||
internal fun foo2() = println("PASS")
|
||||
protected fun foo3() = println("PASS")
|
||||
}
|
||||
|
||||
private class B:A() {
|
||||
fun foo4() = foo3()
|
||||
}
|
||||
|
||||
// Private interfaces
|
||||
private interface C {
|
||||
fun foo() = println("PASS")
|
||||
}
|
||||
|
||||
private class D: C
|
||||
|
||||
fun runner() {
|
||||
B().foo1()
|
||||
B().foo2()
|
||||
B().foo4()
|
||||
|
||||
D().foo()
|
||||
|
||||
// Objects
|
||||
object : A(){
|
||||
fun foo4() = foo3()
|
||||
}.apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo4()
|
||||
}
|
||||
|
||||
// Function local classes
|
||||
abstract class E {
|
||||
public open fun foo1() = println("PASS")
|
||||
internal open fun foo2() = println("PASS")
|
||||
protected open fun foo3() = println("PASS")
|
||||
}
|
||||
class F : E() {
|
||||
fun foo4() = foo3()
|
||||
}
|
||||
F().foo1()
|
||||
F().foo2()
|
||||
F().foo4()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
fun main() {
|
||||
runner()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
// Private classes
|
||||
private open class A {
|
||||
public open fun foo1() = println("FAIL")
|
||||
internal open fun foo2() = println("FAIL")
|
||||
protected open fun foo3() = println("FAIL")
|
||||
private fun foo4() = println("FAIL")
|
||||
}
|
||||
|
||||
private class B:A() {
|
||||
override public fun foo1() = println("PASS")
|
||||
override internal fun foo2() = println("PASS")
|
||||
override protected fun foo3() = println("PASS")
|
||||
private fun foo4() = println("PASS")
|
||||
fun foo5() = foo3()
|
||||
fun foo6() = foo4()
|
||||
}
|
||||
|
||||
private abstract class G {
|
||||
public abstract fun foo1()
|
||||
internal abstract fun foo2()
|
||||
protected abstract fun foo3()
|
||||
private fun foo4() = println("FAIL")
|
||||
}
|
||||
|
||||
private class H:A() {
|
||||
override public fun foo1() = println("PASS")
|
||||
override internal fun foo2() = println("PASS")
|
||||
override protected fun foo3() = println("PASS")
|
||||
private fun foo4() = println("PASS")
|
||||
fun foo5() = foo3()
|
||||
fun foo6() = foo4()
|
||||
}
|
||||
|
||||
|
||||
// Private interfaces
|
||||
private interface C {
|
||||
fun foo() = println("FAIL")
|
||||
}
|
||||
|
||||
private class D: C {
|
||||
override fun foo() = println("PASS")
|
||||
}
|
||||
|
||||
fun runner() {
|
||||
B().foo1()
|
||||
B().foo2()
|
||||
B().foo5()
|
||||
B().foo6()
|
||||
|
||||
H().foo1()
|
||||
H().foo2()
|
||||
H().foo5()
|
||||
H().foo6()
|
||||
|
||||
D().foo()
|
||||
|
||||
// Objects
|
||||
object : A(){
|
||||
override public fun foo1() = println("PASS")
|
||||
override internal fun foo2() = println("PASS")
|
||||
override protected fun foo3() = println("PASS")
|
||||
private fun foo4() = println("PASS")
|
||||
fun foo5() = foo3()
|
||||
fun foo6() = foo4()
|
||||
}.apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo5()
|
||||
foo6()
|
||||
}
|
||||
|
||||
// Function local classes
|
||||
open class E {
|
||||
public open fun foo1() = println("FAIL")
|
||||
internal open fun foo2() = println("FAIL")
|
||||
protected open fun foo3() = println("FAIL")
|
||||
private fun foo4() = println("FAIL")
|
||||
}
|
||||
class F : E() {
|
||||
public override fun foo1() = println("PASS")
|
||||
internal override fun foo2() = println("PASS")
|
||||
protected override fun foo3() = println("PASS")
|
||||
private fun foo4() = println("PASS")
|
||||
fun foo5() = foo3()
|
||||
fun foo6() = foo4()
|
||||
}
|
||||
F().foo1()
|
||||
F().foo2()
|
||||
F().foo5()
|
||||
F().foo6()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
fun main() {
|
||||
runner()
|
||||
}
|
||||
Reference in New Issue
Block a user