FIR resolve: add test for firstOrNull
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a3806a6e2e
commit
d1b8ca31c0
@@ -0,0 +1,11 @@
|
|||||||
|
interface G {
|
||||||
|
val a: Array<out G>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun goo(g: G) {
|
||||||
|
val x = g.a.firstOrNullX()
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <T> Array<out T>.firstOrNullX(): T? {
|
||||||
|
return if (isEmpty()) null else this[0]
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
FILE: arrayFirstOrNull.kt
|
||||||
|
public abstract interface G : R|kotlin/Any| {
|
||||||
|
public abstract val a: R|kotlin/Array<out G>|
|
||||||
|
public get(): R|kotlin/Array<out G>|
|
||||||
|
|
||||||
|
}
|
||||||
|
public final fun goo(g: R|G|): R|kotlin/Unit| {
|
||||||
|
lval x: R|G|? = R|<local>/g|.R|/G.a|.R|/firstOrNullX|<R|G|>()
|
||||||
|
}
|
||||||
|
public final fun <T> R|kotlin/Array<out T>|.firstOrNullX(): R|T|? {
|
||||||
|
^firstOrNullX when () {
|
||||||
|
<Unresolved name: isEmpty>#() -> {
|
||||||
|
Null(null)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
this#.R|FakeOverride<kotlin/Array.get: R|T|>|(Int(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Generated
+5
@@ -29,6 +29,11 @@ public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("arrayFirstOrNull.kt")
|
||||||
|
public void testArrayFirstOrNull() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/arrayFirstOrNull.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("concurrent.kt")
|
@TestMetadata("concurrent.kt")
|
||||||
public void testConcurrent() throws Exception {
|
public void testConcurrent() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/stdlib/concurrent.kt");
|
runTest("compiler/fir/resolve/testData/resolve/stdlib/concurrent.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user