Method can be hidden if it is annotated with kotlin.internal.PlatformDependent,

or is a Java method from a Kotlin built-in class (transitively).

https://github.com/Kotlin/KEEP/blob/master/proposals/jdk-dependent-built-ins.md#backward-compatibility-of-overrides
This commit is contained in:
Dmitry Petrov
2016-12-21 10:49:57 +03:00
parent d9271b54fb
commit 8d16bd1215
22 changed files with 661 additions and 12 deletions
@@ -0,0 +1,32 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
// Default methods from Java interfaces are NOT overridden by delegation.
// So, in the example below 'TestNoDelegationToDefaultMethods#replace' implicitly overrides a method from 'java.util.Map' (which is ok),
// but not a method from 'WithDelegation' (would be an error).
open class WithDelegation(val m: Map<String, String>) : Map<String, String> by m
class TestNoDelegationToDefaultMethods(m: Map<String, String>): WithDelegation(m) {
<!VIRTUAL_MEMBER_HIDDEN!>fun containsKey(key: String): Boolean<!> = TODO()
fun getOrDefault(key: String, defaultValue: String): String = TODO()
fun replace(key: String, value: String): String? = TODO()
}
interface IBaseWithKotlinDeclaration : Map<String, String> {
fun replace(key: String, value: String): String?
}
abstract class WithDelegation2(val m: Map<String, String>) : Map<String, String> by m, IBaseWithKotlinDeclaration
abstract class TestNoDelegationToDefaultMethods2(m: Map<String, String>): WithDelegation2(m) {
<!VIRTUAL_MEMBER_HIDDEN!>fun containsKey(key: String): Boolean<!> = TODO()
fun getOrDefault(key: String, defaultValue: String): String = TODO()
// VIRTUAL_MEMBER_HIDDEN: hides member declaration inherited from a Kotlin interface
<!VIRTUAL_MEMBER_HIDDEN!>fun replace(key: String, value: String): String?<!> = TODO()
}