KT-13426: store map from ImplicitReceiver into KotlinType for implicit receiver smart casts
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
interface IA
|
||||
interface IB
|
||||
interface IC
|
||||
|
||||
object Host : IB
|
||||
|
||||
object Prop : IA {
|
||||
val Host.foo: Callee <info descr="null">get</info>() = Callee
|
||||
}
|
||||
|
||||
object Callee
|
||||
|
||||
object Invoke : IC {
|
||||
<info descr="null">operator</info> fun Callee.invoke() { }
|
||||
}
|
||||
|
||||
<info descr="null">public</info> <info descr="null">inline</info> fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
|
||||
|
||||
fun test(a: IA, b: IB, c: IC) {
|
||||
with(a) lambdaA@{
|
||||
with(b) lambdaB@{
|
||||
with(c) lambdaC@{
|
||||
if (this@lambdaA is Prop && this@lambdaB is Host && this@lambdaC is Invoke) {
|
||||
<info descr="Extension implicit receiver smart cast to Host"><info descr="Extension implicit receiver smart cast to Prop">foo</info></info>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
interface IA
|
||||
interface IB
|
||||
|
||||
object A : IA {
|
||||
fun B.foo() { }
|
||||
}
|
||||
|
||||
object B : IB
|
||||
|
||||
<info descr="null">public</info> <info descr="null">inline</info> fun <T, R> with(receiver: T, block: T.() -> R): R = receiver.block()
|
||||
|
||||
fun test(a: IA, b: IB) {
|
||||
with(a) lambda1@{
|
||||
with(b) lambda2@{
|
||||
if (this@lambda1 is A && this@lambda2 is B) {
|
||||
<info descr="Extension implicit receiver smart cast to A"><info descr="Extension implicit receiver smart cast to B">foo</info></info>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user