[FIR] Add test imitating complex smart casts on descriptors
This commit is contained in:
@@ -6,15 +6,21 @@ public interface Descriptor
|
||||
// FILE: ResolvedCall.java
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ResolvedCall<D extends Descriptor> {
|
||||
@NotNull
|
||||
D getResultingDescriptor();
|
||||
|
||||
@Nullable
|
||||
D getCandidateDescriptor();
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
val Descriptor.name = "123"
|
||||
fun Descriptor.correct(): Boolean = true
|
||||
fun Descriptor.foo() {}
|
||||
|
||||
interface Call<D : Descriptor> {
|
||||
val resultingDescriptor: D
|
||||
@@ -23,6 +29,10 @@ interface Call<D : Descriptor> {
|
||||
fun <D : Descriptor> test(call: Call<D>, resolvedCall: ResolvedCall<D>) {
|
||||
call.resultingDescriptor.name
|
||||
resolvedCall.resultingDescriptor.name
|
||||
|
||||
val resolvedDescriptor = resolvedCall.candidateDescriptor
|
||||
if (resolvedDescriptor?.correct() != true) return
|
||||
resolvedDescriptor.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
}
|
||||
|
||||
fun otherTest(call: Call<*>, resolvedCall: ResolvedCall<*>) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
FILE: test.kt
|
||||
public final val R|Descriptor|.name: R|kotlin/String| = String(123)
|
||||
public get(): R|kotlin/String|
|
||||
public final fun R|Descriptor|.correct(): R|kotlin/Boolean| {
|
||||
^correct Boolean(true)
|
||||
}
|
||||
public final fun R|Descriptor|.foo(): R|kotlin/Unit| {
|
||||
}
|
||||
public abstract interface Call<D : R|Descriptor|> : R|kotlin/Any| {
|
||||
public abstract val resultingDescriptor: R|D|
|
||||
public get(): R|D|
|
||||
@@ -9,6 +14,14 @@ FILE: test.kt
|
||||
public final fun <D : R|Descriptor|> test(call: R|Call<D>|, resolvedCall: R|ResolvedCall<D>|): R|kotlin/Unit| {
|
||||
R|<local>/call|.R|FakeOverride</Call.resultingDescriptor: R|D|>|.R|/name|
|
||||
R|<local>/resolvedCall|.R|/ResolvedCall.resultingDescriptor|.R|/name|
|
||||
lval resolvedDescriptor: R|D?| = R|<local>/resolvedCall|.R|/ResolvedCall.candidateDescriptor|
|
||||
when () {
|
||||
!=(R|<local>/resolvedDescriptor|?.R|/correct|(), Boolean(true)) -> {
|
||||
^test Unit
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/resolvedDescriptor|.<Inapplicable(WRONG_RECEIVER): [/foo]>#()
|
||||
}
|
||||
public final fun otherTest(call: R|Call<*>|, resolvedCall: R|ResolvedCall<*>|): R|kotlin/Unit| {
|
||||
R|<local>/call|.R|FakeOverride</Call.resultingDescriptor: R|Descriptor|>|.R|/name|
|
||||
|
||||
Reference in New Issue
Block a user