Add resolution status to report about unsuccessful smartcast
#KT-10248 Fixed #KT-11119 Fixed
This commit is contained in:
compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/nullableReceiverWithOverloadedMethod.kt
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A {
|
||||
fun f(x: Boolean): Int = 0
|
||||
|
||||
fun f(y: String): Int = 0
|
||||
}
|
||||
|
||||
class B {
|
||||
private var a: A? = null
|
||||
|
||||
fun takeInt(i: Int) {}
|
||||
|
||||
fun f() {
|
||||
a = A()
|
||||
<!SMARTCAST_IMPOSSIBLE!>a<!>.f(true)
|
||||
takeInt(<!SMARTCAST_IMPOSSIBLE!>a<!>.f(""))
|
||||
a.<!NONE_APPLICABLE!>f<!>()
|
||||
}
|
||||
|
||||
fun g() {
|
||||
takeInt(if (3 > 2) {
|
||||
a = A()
|
||||
<!SMARTCAST_IMPOSSIBLE!>a<!>.f(true)
|
||||
} else {
|
||||
6
|
||||
})
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun f(/*0*/ x: kotlin.Boolean): kotlin.Int
|
||||
public final fun f(/*0*/ y: kotlin.String): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
private final var a: A?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun f(): kotlin.Unit
|
||||
public final fun g(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun takeInt(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Ctx
|
||||
class CtxImpl : Ctx {
|
||||
fun doJob(a: Int) {}
|
||||
fun doJob(s: String) {}
|
||||
}
|
||||
|
||||
open class Test(open val ctx: Ctx) {
|
||||
fun test() {
|
||||
when (ctx) {
|
||||
is CtxImpl -> <!SMARTCAST_IMPOSSIBLE!>ctx<!>.doJob(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public interface Ctx {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class CtxImpl : Ctx {
|
||||
public constructor CtxImpl()
|
||||
public final fun doJob(/*0*/ a: kotlin.Int): kotlin.Unit
|
||||
public final fun doJob(/*0*/ s: kotlin.String): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Test {
|
||||
public constructor Test(/*0*/ ctx: Ctx)
|
||||
public open val ctx: Ctx
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A
|
||||
class B
|
||||
|
||||
fun A.foo(a: A) {}
|
||||
fun A.foo(b: B) {}
|
||||
var a: A? = null
|
||||
|
||||
fun smartCastInterference(b: B) {
|
||||
if (a != null) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>a<!>.foo(b)
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public var a: A?
|
||||
public fun smartCastInterference(/*0*/ b: B): kotlin.Unit
|
||||
public fun A.foo(/*0*/ a: A): kotlin.Unit
|
||||
public fun A.foo(/*0*/ b: B): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user