[IR][tests] Add cases to visibility-related tests where a callable accidentally starts to override newly added open callable in super class

^KT-53608
This commit is contained in:
Dmitriy Dolovov
2022-09-13 19:03:45 +02:00
parent ec4b85b111
commit cd007c02df
8 changed files with 175 additions and 0 deletions
@@ -17,4 +17,12 @@ open class Container {
protected open fun protectedToPublicOverriddenFunction() = "Container.protectedToPublicOverriddenFunction.v1"
protected open fun protectedToInternalOverriddenFunction() = "Container.protectedToInternalOverriddenFunction.v1"
protected open fun protectedToPrivateOverriddenFunction() = "Container.protectedToPrivateOverriddenFunction.v1"
// public fun newPublicFunction() = "Container.newPublicFunction.v1"
// public open fun newOpenPublicFunction() = "Container.newOpenPublicFunction.v1"
// protected fun newProtectedFunction() = "Container.newProtectedFunction.v1"
// protected open fun newOpenProtectedFunction() = "Container.newOpenProtectedFunction.v1"
// internal fun newInternalFunction() = "Container.newInternalFunction.v1"
// internal open fun newOpenInternalFunction() = "Container.newOpenInternalFunction.v1"
// private fun newPrivateFunction() = "Container.newPrivateFunction.v1"
}
@@ -17,4 +17,12 @@ open class Container {
public open fun protectedToPublicOverriddenFunction() = "Container.protectedToPublicOverriddenFunction.v2"
internal open fun protectedToInternalOverriddenFunction() = "Container.protectedToInternalOverriddenFunction.v2"
private /*open*/ fun protectedToPrivateOverriddenFunction() = "Container.protectedToPrivateOverriddenFunction.v2"
public fun newPublicFunction() = "Container.newPublicFunction.v2"
public open fun newOpenPublicFunction() = "Container.newOpenPublicFunction.v2"
protected fun newProtectedFunction() = "Container.newProtectedFunction.v2"
protected open fun newOpenProtectedFunction() = "Container.newOpenProtectedFunction.v2"
internal fun newInternalFunction() = "Container.newInternalFunction.v2"
internal open fun newOpenInternalFunction() = "Container.newOpenInternalFunction.v2"
private fun newPrivateFunction() = "Container.newPrivateFunction.v2"
}
@@ -22,4 +22,21 @@ class ContainerImpl : Container() {
fun protectedToPublicOverriddenFunctionAccess() = protectedToPublicOverriddenFunction()
fun protectedToInternalOverriddenFunctionAccess() = protectedToInternalOverriddenFunction()
fun protectedToPrivateOverriddenFunctionAccess() = protectedToPrivateOverriddenFunction()
// Functions that accedentally start to override/conflict with functions added to Container since version v2:
public fun newPublicFunction() = "ContainerImpl.newPublicFunction"
public fun newOpenPublicFunction() = "ContainerImpl.newOpenPublicFunction"
protected fun newProtectedFunction() = "ContainerImpl.newProtectedFunction"
protected fun newOpenProtectedFunction() = "ContainerImpl.newOpenProtectedFunction"
internal fun newInternalFunction() = "ContainerImpl.newInternalFunction"
internal fun newOpenInternalFunction() = "ContainerImpl.newOpenInternalFunction"
private fun newPrivateFunction() = "ContainerImpl.newPrivateFunction"
// As far as protected/private members can't be accessed outside of the class hierarchy, and internal can't be accessed
// outside of module, we need special accessors.
fun newProtectedFunctionAccess() = newProtectedFunction()
fun newOpenProtectedFunctionAccess() = newOpenProtectedFunction()
fun newInternalFunctionAccess() = newInternalFunction()
fun newOpenInternalFunctionAccess() = newOpenInternalFunction()
fun newPrivateFunctionAccess() = newPrivateFunction()
}
@@ -19,4 +19,11 @@ fun box() = abiTest {
expectSuccess("ContainerImpl.protectedToPublicOverriddenFunction") { c.protectedToPublicOverriddenFunctionAccess() }
expectSuccess("ContainerImpl.protectedToInternalOverriddenFunction") { c.protectedToInternalOverriddenFunctionAccess() }
expectSuccess("ContainerImpl.protectedToPrivateOverriddenFunction") { c.protectedToPrivateOverriddenFunctionAccess() }
expectSuccess("ContainerImpl.newPublicFunction") { c.newPublicFunction() }
expectSuccess("ContainerImpl.newOpenPublicFunction") { c.newOpenPublicFunction() }
expectSuccess("ContainerImpl.newProtectedFunction") { c.newProtectedFunctionAccess() }
expectSuccess("ContainerImpl.newOpenProtectedFunction") { c.newOpenProtectedFunctionAccess() }
expectSuccess("ContainerImpl.newInternalFunction") { c.newInternalFunctionAccess() }
expectSuccess("ContainerImpl.newOpenInternalFunction") { c.newOpenInternalFunctionAccess() }
expectSuccess("ContainerImpl.newPrivateFunction") { c.newPrivateFunctionAccess() }
}