FIR checker: report VIRTUAL_MEMBER_HIDDEN

This commit is contained in:
Tianyu Geng
2021-05-24 13:29:32 -07:00
committed by Mikhail Glukhikh
parent d3dfb33f89
commit 32f55a2269
30 changed files with 195 additions and 99 deletions
@@ -1,5 +0,0 @@
interface IA {
fun toString(): String = "IB"
override fun equals(other: Any?): Boolean
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface IA {
fun <!VIRTUAL_MEMBER_HIDDEN!>toString<!>(): String = "IB"
@@ -1,15 +0,0 @@
interface X {
fun foo(a : Int = 1)
}
interface Y {
fun foo(a : Int = 1)
}
class Z : X, Y {
fun foo(a : Int) {}
}
object ZO : X, Y {
fun foo(a : Int) {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface X {
fun foo(a : Int = 1)
}
@@ -36,8 +36,8 @@ class MyChildClass() : MyClass() {}
}
<!ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED!>class MyIllegalClass4<!>() : MyTrait, MyAbstractClass() {
fun foo() {}
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val pr : Unit<!>
fun <!VIRTUAL_MEMBER_HIDDEN!>foo<!>() {}
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val <!VIRTUAL_MEMBER_HIDDEN!>pr<!> : Unit<!>
override fun other() {}
override val otherPr : Int = 1
}
@@ -25,7 +25,7 @@ fun test() {
}
class E: A() {
fun foo() = A()
fun <!VIRTUAL_MEMBER_HIDDEN!>foo<!>() = A()
init {
val a: A = foo() // todo: discuss
@@ -1,18 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
abstract class Test1 : Map<String, String> {
fun containsKey(key: String): Boolean = TODO()
fun getOrDefault(key: String, defaultValue: String): String = TODO()
}
abstract class Test2 : MutableMap<String, String> {
fun replace(key: String, value: String): String? = TODO()
}
abstract class Test3 : java.util.AbstractMap<String, String>() {
fun containsKey(key: String): Boolean = TODO()
fun replace(key: String, value: String): String? = TODO()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
abstract class Test1 : Map<String, String> {
@@ -1,32 +0,0 @@
// !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) {
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) {
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
fun replace(key: String, value: String): String? = TODO()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
@@ -1,15 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
interface IBaseWithKotlinDeclaration : Map<String, String> {
fun replace(key: String, value: String): String?
}
interface TestDerivedInterfaceHidingWithKotlinDeclaration : IBaseWithKotlinDeclaration {
// VIRTUAL_MEMBER_HIDDEN: hides member declaration inherited from a Kotlin interface
fun replace(key: String, value: String): String?
}
interface TestDerivedInterfaceDefaultWithKotlinDeclaration : IBaseWithKotlinDeclaration {
// VIRTUAL_MEMBER_HIDDEN: hides member declaration inherited from a Kotlin interface
fun replace(key: String, value: String): String? = TODO()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -PLATFORM_CLASS_MAPPED_TO_KOTLIN
interface IBaseWithKotlinDeclaration : Map<String, String> {
@@ -14,11 +14,11 @@ class A : java.util.ArrayList<String>() {
}
class A1 : java.util.ArrayList<String>() {
// `stream` is defined in ArrayList, so it was possible to declare it in 1.0 without an 'override' keyword
// `stream` is defined in Collection, so it was possible to declare it in 1.0 without an 'override' keyword
fun stream(): java.util.stream.Stream<String> = super.stream()
// `sort` is defined in ArrayList, so it was impossible to declare it in 1.0 without an 'override' keyword
fun sort(c: Comparator<in String>?) {
fun <!VIRTUAL_MEMBER_HIDDEN!>sort<!>(c: Comparator<in String>?) {
super.sort(c)
}
}
@@ -14,7 +14,7 @@ class A : java.util.ArrayList<String>() {
}
class A1 : java.util.ArrayList<String>() {
// `stream` is defined in ArrayList, so it was possible to declare it in 1.0 without an 'override' keyword
// `stream` is defined in Collection, so it was possible to declare it in 1.0 without an 'override' keyword
fun stream(): java.util.stream.Stream<String> = super.<!UNRESOLVED_REFERENCE!>stream<!>()
// `sort` is defined in ArrayList, so it was impossible to declare it in 1.0 without an 'override' keyword