KT-61728 [LL API] Add extra test for smartcast inside let

This commit is contained in:
Roman Golyshev
2023-09-08 12:50:03 +02:00
committed by Space Team
parent a20dea1b0a
commit 370a6fb461
3 changed files with 53 additions and 0 deletions
@@ -0,0 +1,7 @@
fun foo(param: String?): String {
param?.let {
return <expr>param</expr>
}
return ""
}
@@ -0,0 +1,40 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirDefaultSimpleImportingScope
Element 2
Scope: FirExplicitStarImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirDefaultSimpleImportingScope
Element 5
Scope: FirPackageMemberScope
Element 6
Scope: FirExplicitSimpleImportingScope
Element 7
Scope: FirLocalScope
Properties:
FirValueParameterSymbol param: R|kotlin/String?|
Element 8
Scope: FirLocalScope
Element 9
Scope: FirLocalScope
Properties:
FirValueParameterSymbol it: R|kotlin/String|
Element 10
Scope: FirLocalScope
Smart Casts:
FirValueParameterSymbol param: R|kotlin/String?|
Types:
kotlin/Any
FILE: [ResolvedTo(IMPORTS)] insideLetOnNullableReceiver.kt
public final [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] param: R|kotlin/String?|): R|kotlin/String| {
R|<local>/param|?.{ $subj$.R|kotlin/let|<R|kotlin/String|, R|kotlin/Nothing|>(<L> = [ResolvedTo(BODY_RESOLVE)] let@fun <anonymous>([ResolvedTo(BODY_RESOLVE)] it: R|kotlin/String|): R|kotlin/Nothing| <inline=Inline, kind=EXACTLY_ONCE> {
^foo R|<local>/param|
}
) }
^foo String()
}
@@ -257,6 +257,12 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto
runTest("analysis/low-level-api-fir/testdata/contextCollector/smartCasts/extensionReceiver.kt");
}
@Test
@TestMetadata("insideLetOnNullableReceiver.kt")
public void testInsideLetOnNullableReceiver() throws Exception {
runTest("analysis/low-level-api-fir/testdata/contextCollector/smartCasts/insideLetOnNullableReceiver.kt");
}
@Test
@TestMetadata("insideLoop.kt")
public void testInsideLoop() throws Exception {