[FIR TEST]: add problematic test with covariant array as receiver
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
interface UsageInfo {
|
||||
val usage: PsiElement
|
||||
}
|
||||
|
||||
interface PsiElement
|
||||
|
||||
interface KtParameter : PsiElement
|
||||
|
||||
interface KtLightMethod : PsiElement
|
||||
|
||||
// With covariant array here we do not visit lambda (it.usage is KtLightMethod) below
|
||||
// Problem disappears if 'out' is removed
|
||||
fun <T> Array<out T>.filterNot(f: (T) -> Boolean): List<T> {
|
||||
return this
|
||||
}
|
||||
|
||||
fun <T> Array<T>.toList(): List<T>? = null
|
||||
|
||||
fun foo(element: PsiElement, usages: Array<UsageInfo>) {
|
||||
element is KtLightMethod
|
||||
val adjusted = if (element is KtParameter) usages.filterNot {
|
||||
it.usage is KtLightMethod
|
||||
} else usages.toList()
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
FILE: covariantArrayAsReceiver.kt
|
||||
public abstract interface UsageInfo : R|kotlin/Any| {
|
||||
public abstract val usage: R|PsiElement|
|
||||
public get(): R|PsiElement|
|
||||
|
||||
}
|
||||
public abstract interface PsiElement : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface KtParameter : R|PsiElement| {
|
||||
}
|
||||
public abstract interface KtLightMethod : R|PsiElement| {
|
||||
}
|
||||
public final fun <T> R|kotlin/Array<out T>|.filterNot(f: R|(T) -> kotlin/Boolean|): R|kotlin/collections/List<T>| {
|
||||
^filterNot this@R|/filterNot|
|
||||
}
|
||||
public final fun <T> R|kotlin/Array<T>|.toList(): R|kotlin/collections/List<T>?| {
|
||||
^toList Null(null)
|
||||
}
|
||||
public final fun foo(element: R|PsiElement|, usages: R|kotlin/Array<UsageInfo>|): R|kotlin/Unit| {
|
||||
(R|<local>/element| is R|KtLightMethod|)
|
||||
lval adjusted: R|kotlin/collections/List<UsageInfo>?| = when () {
|
||||
(R|<local>/element| is R|KtParameter|) -> {
|
||||
R|<local>/usages|.R|/filterNot|<R|UsageInfo|>(<L> = filterNot@fun <implicit>.<anonymous>(): <implicit> {
|
||||
(it#.usage# is KtLightMethod)
|
||||
}
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
R|<local>/usages|.R|/toList|<R|UsageInfo|>()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -941,6 +941,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/asImports.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("covariantArrayAsReceiver.kt")
|
||||
public void testCovariantArrayAsReceiver() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/covariantArrayAsReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultJavaImportHiding.kt")
|
||||
public void testDefaultJavaImportHiding() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/problems/defaultJavaImportHiding.kt");
|
||||
|
||||
Reference in New Issue
Block a user