[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() }
}
@@ -43,4 +43,33 @@ open class Container {
protected open val protectedToPrivateOverriddenProperty2 get() = "Container.protectedToPrivateOverriddenProperty2.v1"
protected open val protectedToPrivateOverriddenProperty3 = "Container.protectedToPrivateOverriddenProperty3.v1"
protected open val protectedToPrivateOverriddenProperty4 get() = "Container.protectedToPrivateOverriddenProperty4.v1"
// public val newPublicProperty1 = "Container.newPublicProperty1.v1"
// public val newPublicProperty2 get() = "Container.newPublicProperty2.v1"
// public val newPublicProperty3 = "Container.newPublicProperty3.v1"
// public val newPublicProperty4 get() = "Container.newPublicProperty4.v1"
// public open val newOpenPublicProperty1 = "Container.newOpenPublicProperty1.v1"
// public open val newOpenPublicProperty2 get() = "Container.newOpenPublicProperty2.v1"
// public open val newOpenPublicProperty3 = "Container.newOpenPublicProperty3.v1"
// public open val newOpenPublicProperty4 get() = "Container.newOpenPublicProperty4.v1"
// protected val newProtectedProperty1 = "Container.newProtectedProperty1.v1"
// protected val newProtectedProperty2 get() = "Container.newProtectedProperty2.v1"
// protected val newProtectedProperty3 = "Container.newProtectedProperty3.v1"
// protected val newProtectedProperty4 get() = "Container.newProtectedProperty4.v1"
// protected open val newOpenProtectedProperty1 = "Container.newOpenProtectedProperty1.v1"
// protected open val newOpenProtectedProperty2 get() = "Container.newOpenProtectedProperty2.v1"
// protected open val newOpenProtectedProperty3 = "Container.newOpenProtectedProperty3.v1"
// protected open val newOpenProtectedProperty4 get() = "Container.newOpenProtectedProperty4.v1"
// internal val newInternalProperty1 = "Container.newInternalProperty1.v1"
// internal val newInternalProperty2 get() = "Container.newInternalProperty2.v1"
// internal val newInternalProperty3 = "Container.newInternalProperty3.v1"
// internal val newInternalProperty4 get() = "Container.newInternalProperty4.v1"
// internal open val newOpenInternalProperty1 = "Container.newOpenInternalProperty1.v1"
// internal open val newOpenInternalProperty2 get() = "Container.newOpenInternalProperty2.v1"
// internal open val newOpenInternalProperty3 = "Container.newOpenInternalProperty3.v1"
// internal open val newOpenInternalProperty4 get() = "Container.newOpenInternalProperty4.v1"
// private val newPrivateProperty1 = "Container.newPrivateProperty1.v1"
// private val newPrivateProperty2 get() = "Container.newPrivateProperty2.v1"
// private val newPrivateProperty3 = "Container.newPrivateProperty3.v1"
// private val newPrivateProperty4 get() = "Container.newPrivateProperty4.v1"
}
@@ -43,4 +43,33 @@ open class Container {
private /*open*/ val protectedToPrivateOverriddenProperty2 get() = "Container.protectedToPrivateOverriddenProperty2.v2"
private /*open*/ val protectedToPrivateOverriddenProperty3 get() = "Container.protectedToPrivateOverriddenProperty3.v2"
private /*open*/ val protectedToPrivateOverriddenProperty4 = "Container.protectedToPrivateOverriddenProperty4.v2"
public val newPublicProperty1 = "Container.newPublicProperty1.v2"
public val newPublicProperty2 get() = "Container.newPublicProperty2.v2"
public val newPublicProperty3 = "Container.newPublicProperty3.v2"
public val newPublicProperty4 get() = "Container.newPublicProperty4.v2"
public open val newOpenPublicProperty1 = "Container.newOpenPublicProperty1.v2"
public open val newOpenPublicProperty2 get() = "Container.newOpenPublicProperty2.v2"
public open val newOpenPublicProperty3 = "Container.newOpenPublicProperty3.v2"
public open val newOpenPublicProperty4 get() = "Container.newOpenPublicProperty4.v2"
protected val newProtectedProperty1 = "Container.newProtectedProperty1.v2"
protected val newProtectedProperty2 get() = "Container.newProtectedProperty2.v2"
protected val newProtectedProperty3 = "Container.newProtectedProperty3.v2"
protected val newProtectedProperty4 get() = "Container.newProtectedProperty4.v2"
protected open val newOpenProtectedProperty1 = "Container.newOpenProtectedProperty1.v2"
protected open val newOpenProtectedProperty2 get() = "Container.newOpenProtectedProperty2.v2"
protected open val newOpenProtectedProperty3 = "Container.newOpenProtectedProperty3.v2"
protected open val newOpenProtectedProperty4 get() = "Container.newOpenProtectedProperty4.v2"
internal val newInternalProperty1 = "Container.newInternalProperty1.v2"
internal val newInternalProperty2 get() = "Container.newInternalProperty2.v2"
internal val newInternalProperty3 = "Container.newInternalProperty3.v2"
internal val newInternalProperty4 get() = "Container.newInternalProperty4.v2"
internal open val newOpenInternalProperty1 = "Container.newOpenInternalProperty1.v2"
internal open val newOpenInternalProperty2 get() = "Container.newOpenInternalProperty2.v2"
internal open val newOpenInternalProperty3 = "Container.newOpenInternalProperty3.v2"
internal open val newOpenInternalProperty4 get() = "Container.newOpenInternalProperty4.v2"
private val newPrivateProperty1 = "Container.newPrivateProperty1.v2"
private val newPrivateProperty2 get() = "Container.newPrivateProperty2.v2"
private val newPrivateProperty3 = "Container.newPrivateProperty3.v2"
private val newPrivateProperty4 get() = "Container.newPrivateProperty4.v2"
}
@@ -55,4 +55,57 @@ class ContainerImpl : Container() {
fun protectedToPrivateOverriddenProperty2Access() = protectedToPrivateOverriddenProperty2
fun protectedToPrivateOverriddenProperty3Access() = protectedToPrivateOverriddenProperty3
fun protectedToPrivateOverriddenProperty4Access() = protectedToPrivateOverriddenProperty4
// Properties that accedentally start to override/conflict with properties added to Container since version v2:
public val newPublicProperty1 = "ContainerImpl.newPublicProperty1"
public val newPublicProperty2 get() = "ContainerImpl.newPublicProperty2"
public val newPublicProperty3 get() = "ContainerImpl.newPublicProperty3"
public val newPublicProperty4 = "ContainerImpl.newPublicProperty4"
public open val newOpenPublicProperty1 = "ContainerImpl.newOpenPublicProperty1"
public open val newOpenPublicProperty2 get() = "ContainerImpl.newOpenPublicProperty2"
public open val newOpenPublicProperty3 get() = "ContainerImpl.newOpenPublicProperty3"
public open val newOpenPublicProperty4 = "ContainerImpl.newOpenPublicProperty4"
protected val newProtectedProperty1 = "ContainerImpl.newProtectedProperty1"
protected val newProtectedProperty2 get() = "ContainerImpl.newProtectedProperty2"
protected val newProtectedProperty3 get() = "ContainerImpl.newProtectedProperty3"
protected val newProtectedProperty4 = "ContainerImpl.newProtectedProperty4"
protected open val newOpenProtectedProperty1 = "ContainerImpl.newOpenProtectedProperty1"
protected open val newOpenProtectedProperty2 get() = "ContainerImpl.newOpenProtectedProperty2"
protected open val newOpenProtectedProperty3 get() = "ContainerImpl.newOpenProtectedProperty3"
protected open val newOpenProtectedProperty4 = "ContainerImpl.newOpenProtectedProperty4"
internal val newInternalProperty1 = "ContainerImpl.newInternalProperty1"
internal val newInternalProperty2 get() = "ContainerImpl.newInternalProperty2"
internal val newInternalProperty3 get() = "ContainerImpl.newInternalProperty3"
internal val newInternalProperty4 = "ContainerImpl.newInternalProperty4"
internal open val newOpenInternalProperty1 = "ContainerImpl.newOpenInternalProperty1"
internal open val newOpenInternalProperty2 get() = "ContainerImpl.newOpenInternalProperty2"
internal open val newOpenInternalProperty3 get() = "ContainerImpl.newOpenInternalProperty3"
internal open val newOpenInternalProperty4 = "ContainerImpl.newOpenInternalProperty4"
private val newPrivateProperty1 = "ContainerImpl.newPrivateProperty1"
private val newPrivateProperty2 get() = "ContainerImpl.newPrivateProperty2"
private val newPrivateProperty3 get() = "ContainerImpl.newPrivateProperty3"
private val newPrivateProperty4 = "ContainerImpl.newPrivateProperty4"
// 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 newProtectedProperty1Access() = newProtectedProperty1
fun newProtectedProperty2Access() = newProtectedProperty2
fun newProtectedProperty3Access() = newProtectedProperty3
fun newProtectedProperty4Access() = newProtectedProperty4
fun newOpenProtectedProperty1Access() = newOpenProtectedProperty1
fun newOpenProtectedProperty2Access() = newOpenProtectedProperty2
fun newOpenProtectedProperty3Access() = newOpenProtectedProperty3
fun newOpenProtectedProperty4Access() = newOpenProtectedProperty4
fun newInternalProperty1Access() = newInternalProperty1
fun newInternalProperty2Access() = newInternalProperty2
fun newInternalProperty3Access() = newInternalProperty3
fun newInternalProperty4Access() = newInternalProperty4
fun newOpenInternalProperty1Access() = newOpenInternalProperty1
fun newOpenInternalProperty2Access() = newOpenInternalProperty2
fun newOpenInternalProperty3Access() = newOpenInternalProperty3
fun newOpenInternalProperty4Access() = newOpenInternalProperty4
fun newPrivateProperty1Access() = newPrivateProperty1
fun newPrivateProperty2Access() = newPrivateProperty2
fun newPrivateProperty3Access() = newPrivateProperty3
fun newPrivateProperty4Access() = newPrivateProperty4
}
@@ -48,4 +48,28 @@ fun box() = abiTest {
expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty2") { c.protectedToPrivateOverriddenProperty2Access() }
expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty3") { c.protectedToPrivateOverriddenProperty3Access() }
expectSuccess("ContainerImpl.protectedToPrivateOverriddenProperty4") { c.protectedToPrivateOverriddenProperty4Access() }
expectSuccess("ContainerImpl.newPublicProperty1") { c.newPublicProperty1 }
expectSuccess("ContainerImpl.newPublicProperty2") { c.newPublicProperty2 }
expectSuccess("ContainerImpl.newPublicProperty3") { c.newPublicProperty3 }
expectSuccess("ContainerImpl.newPublicProperty4") { c.newPublicProperty4 }
expectSuccess("ContainerImpl.newProtectedProperty1") { c.newProtectedProperty1Access() }
expectSuccess("ContainerImpl.newProtectedProperty2") { c.newProtectedProperty2Access() }
expectSuccess("ContainerImpl.newProtectedProperty3") { c.newProtectedProperty3Access() }
expectSuccess("ContainerImpl.newProtectedProperty4") { c.newProtectedProperty4Access() }
expectSuccess("ContainerImpl.newOpenProtectedProperty1") { c.newOpenProtectedProperty1Access() }
expectSuccess("ContainerImpl.newOpenProtectedProperty2") { c.newOpenProtectedProperty2Access() }
expectSuccess("ContainerImpl.newOpenProtectedProperty3") { c.newOpenProtectedProperty3Access() }
expectSuccess("ContainerImpl.newOpenProtectedProperty4") { c.newOpenProtectedProperty4Access() }
expectSuccess("ContainerImpl.newInternalProperty1") { c.newInternalProperty1Access() }
expectSuccess("ContainerImpl.newInternalProperty2") { c.newInternalProperty2Access() }
expectSuccess("ContainerImpl.newInternalProperty3") { c.newInternalProperty3Access() }
expectSuccess("ContainerImpl.newInternalProperty4") { c.newInternalProperty4Access() }
expectSuccess("ContainerImpl.newOpenInternalProperty1") { c.newOpenInternalProperty1Access() }
expectSuccess("ContainerImpl.newOpenInternalProperty2") { c.newOpenInternalProperty2Access() }
expectSuccess("ContainerImpl.newOpenInternalProperty3") { c.newOpenInternalProperty3Access() }
expectSuccess("ContainerImpl.newOpenInternalProperty4") { c.newOpenInternalProperty4Access() }
expectSuccess("ContainerImpl.newPrivateProperty1") { c.newPrivateProperty1Access() }
expectSuccess("ContainerImpl.newPrivateProperty2") { c.newPrivateProperty2Access() }
expectSuccess("ContainerImpl.newPrivateProperty3") { c.newPrivateProperty3Access() }
expectSuccess("ContainerImpl.newPrivateProperty4") { c.newPrivateProperty4Access() }
}