[FIR] Add diagnostic CONFLICTING_OVERLOADS & REDECLARATION
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
<!CONFLICTING_OVERLOADS!>fun test(x: Int) {}<!>
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun test(y: Int) {}<!>
|
||||
|
||||
fun test() {}
|
||||
|
||||
fun test(z: Int, c: Char) {}
|
||||
|
||||
<!REDECLARATION!>open class A {
|
||||
open fun rest(s: String) {}
|
||||
|
||||
open val u = 20
|
||||
}<!>
|
||||
|
||||
<!REDECLARATION!>class A {
|
||||
|
||||
}<!>
|
||||
|
||||
<!REDECLARATION!>class B : A {
|
||||
<!CONFLICTING_OVERLOADS!>override fun rest(s: String) {}<!>
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun rest(s: String) {}<!>
|
||||
|
||||
fun rest(l: Long) {}
|
||||
|
||||
override val u = 310
|
||||
}<!>
|
||||
|
||||
<!REDECLARATION!>interface B<!>
|
||||
|
||||
<!REDECLARATION!>enum class B<!>
|
||||
|
||||
<!REDECLARATION!>val u = 10<!>
|
||||
<!REDECLARATION!>val u = 20<!>
|
||||
|
||||
<!REDECLARATION!>typealias TA = A<!>
|
||||
<!REDECLARATION!>typealias TA = B<!>
|
||||
|
||||
typealias BA = A
|
||||
|
||||
fun <T> kek(t: T) where T : (String) -> Any?, T : Char {}
|
||||
fun <T> kek(t: T) where T : () -> Boolean, T : String {}
|
||||
fun <T : Int> kek(t: T) {}
|
||||
|
||||
fun lol(a: Array<Int>) {}
|
||||
fun lol(a: Array<Boolean>) {}
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>fun <T> mem(t: T) where T : () -> Boolean, T : String {}<!>
|
||||
<!CONFLICTING_OVERLOADS!>fun <T> mem(t: T) where T : String, T : () -> Boolean {}<!>
|
||||
|
||||
class M {
|
||||
companion <!REDECLARATION!>object<!> {}
|
||||
<!REDECLARATION!>val Companion = object : Any {}<!>
|
||||
}
|
||||
|
||||
fun B.foo() {}
|
||||
|
||||
class L {
|
||||
fun B.foo() {}
|
||||
}
|
||||
|
||||
fun mest()
|
||||
|
||||
class mest
|
||||
|
||||
fun() {}
|
||||
|
||||
private fun() {}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
FILE: conflictingOverloads.kt
|
||||
public final fun test(x: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(y: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(z: R|kotlin/Int|, c: R|kotlin/Char|): R|kotlin/Unit| {
|
||||
}
|
||||
public open class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public open fun rest(s: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public open val u: R|kotlin/Int| = Int(20)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class B : R|A| {
|
||||
public constructor(): R|B| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
public final override fun rest(s: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun rest(s: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun rest(l: R|kotlin/Long|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final override val u: R|kotlin/Int| = Int(310)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
public abstract interface B : R|kotlin/Any| {
|
||||
}
|
||||
public final enum class B : R|kotlin/Enum<B>| {
|
||||
private constructor(): R|B| {
|
||||
super<R|kotlin/Enum<B>|>()
|
||||
}
|
||||
|
||||
public final static fun values(): R|kotlin/Array<B>| {
|
||||
}
|
||||
|
||||
public final static fun valueOf(value: R|kotlin/String|): R|B| {
|
||||
}
|
||||
|
||||
}
|
||||
public final val u: R|kotlin/Int| = Int(10)
|
||||
public get(): R|kotlin/Int|
|
||||
public final val u: R|kotlin/Int| = Int(20)
|
||||
public get(): R|kotlin/Int|
|
||||
public final typealias TA = R|A|
|
||||
public final typealias TA = R|B|
|
||||
public final typealias BA = R|A|
|
||||
public final fun <T : R|(kotlin/String) -> kotlin/Any?|, R|kotlin/Char|> kek(t: R|T|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun <T : R|() -> kotlin/Boolean|, R|kotlin/String|> kek(t: R|T|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun <T : R|kotlin/Int|> kek(t: R|T|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun lol(a: R|kotlin/Array<kotlin/Int>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun lol(a: R|kotlin/Array<kotlin/Boolean>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun <T : R|() -> kotlin/Boolean|, R|kotlin/String|> mem(t: R|T|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun <T : R|kotlin/String|, R|() -> kotlin/Boolean|> mem(t: R|T|): R|kotlin/Unit| {
|
||||
}
|
||||
public final class M : R|kotlin/Any| {
|
||||
public constructor(): R|M| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|M.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final val Companion: R|<anonymous>| = object : R|kotlin/Any| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public get(): R|<anonymous>|
|
||||
|
||||
}
|
||||
public final fun R|B|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
public final class L : R|kotlin/Any| {
|
||||
public constructor(): R|L| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun R|B|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final fun mest(): R|kotlin/Unit|
|
||||
public final class mest : R|kotlin/Any| {
|
||||
public constructor(): R|mest| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <no name provided>(): R|kotlin/Unit| {
|
||||
}
|
||||
private final fun <no name provided>(): R|kotlin/Unit| {
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
class A {
|
||||
companion object {
|
||||
companion <!REDECLARATION!>object<!> {
|
||||
|
||||
}
|
||||
|
||||
companion <!MANY_COMPANION_OBJECTS!>object<!> {
|
||||
companion <!MANY_COMPANION_OBJECTS, REDECLARATION!>object<!> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
object A
|
||||
<!REDECLARATION!>object A<!>
|
||||
|
||||
val A = 10
|
||||
<!REDECLARATION!>val A = 10<!>
|
||||
|
||||
|
||||
fun foo() = A
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
fun takeString(s: String) {}
|
||||
<!CONFLICTING_OVERLOADS!>fun takeString(s: String) {}<!>
|
||||
|
||||
class Wrapper(val s: String?) {
|
||||
fun withThis() {
|
||||
@@ -11,4 +11,4 @@ class Wrapper(val s: String?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun takeString(s: String) {}
|
||||
<!CONFLICTING_OVERLOADS!>fun takeString(s: String) {}<!>
|
||||
+4
-4
@@ -23,11 +23,11 @@ fun test_2(a: A?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: Any?) {
|
||||
<!CONFLICTING_OVERLOADS!>fun test_3(x: Any?) {
|
||||
val a = x as? A ?: return
|
||||
a.foo() // Should be OK
|
||||
x.foo() // Should be OK
|
||||
}
|
||||
}<!>
|
||||
|
||||
// ----------------- Unstable -----------------
|
||||
|
||||
@@ -53,8 +53,8 @@ fun test_2(a: B?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: Any?) {
|
||||
<!CONFLICTING_OVERLOADS!>fun test_3(x: Any?) {
|
||||
val a = x as? B ?: return
|
||||
a.foo() // Should be OK
|
||||
x.foo() // Should be OK
|
||||
}
|
||||
}<!>
|
||||
@@ -13,7 +13,7 @@ class B()
|
||||
class C(val b : B)
|
||||
fun get(f: Boolean) = if (f) {A.A1} else {""}
|
||||
|
||||
fun case2() {
|
||||
<!CONFLICTING_OVERLOADS!>fun case2() {
|
||||
|
||||
val flag: Any = get(false) //string
|
||||
val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN
|
||||
@@ -25,9 +25,9 @@ fun case2() {
|
||||
A.A1 -> B()
|
||||
A.A2 -> B()
|
||||
}
|
||||
}
|
||||
}<!>
|
||||
|
||||
fun case2() {
|
||||
<!CONFLICTING_OVERLOADS!>fun case2() {
|
||||
|
||||
val flag: Any = get(true) //A
|
||||
val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN
|
||||
@@ -39,7 +39,7 @@ fun case2() {
|
||||
A.A1 -> B()
|
||||
A.A2 -> B()
|
||||
}
|
||||
}
|
||||
}<!>
|
||||
|
||||
fun case3() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user