FIR: Set resolve phase to BODY_RESOLVE for SAM constructor value

parameters.

This was causing exceptions with analysis API trying to resolve the
synthetic FirValueParameter because it could not find a KtDeclaration
for it. Using BODY_RESOLVE should be safe; the SAM constructor function
is also on BODY_RESOLVE and the type of the value parameter is known.
This commit is contained in:
Mark Punzalan
2021-09-30 21:57:40 +00:00
committed by TeamCityServer
parent 32bf7f33a7
commit d16454b9af
6 changed files with 14 additions and 1 deletions
@@ -72,6 +72,7 @@ private fun KtCall.stringRepresentation(): String {
append(
when (this@stringValue) {
is KtFunctionSymbol -> callableIdIfNonLocal ?: name
is KtSamConstructorSymbol -> callableIdIfNonLocal ?: name
is KtConstructorSymbol -> "<constructor>"
is KtPropertyGetterSymbol -> callableIdIfNonLocal ?: "<getter>"
is KtPropertySetterSymbol -> callableIdIfNonLocal ?: "<setter>"
@@ -372,6 +372,12 @@ public class ResolveCallTestGenerated extends AbstractResolveCallTest {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/resolveCallInSuperConstructorParam.kt");
}
@Test
@TestMetadata("samConstructorCall.kt")
public void testSamConstructorCall() throws Exception {
runTest("analysis/analysis-api/testData/analysisSession/resolveCall/samConstructorCall.kt");
}
@Test
@TestMetadata("simpleCallWithNonMatchingArgs.kt")
public void testSimpleCallWithNonMatchingArgs() throws Exception {
@@ -0,0 +1 @@
val c = <expr>Comparator {x: Int, y: Int -> 1}</expr>
@@ -0,0 +1,4 @@
KtFunctionCall:
argumentMapping = { {x: Int, y: Int -> 1} -> (block: kotlin.Function2<ft<kotlin.Int, kotlin.Int?>, ft<kotlin.Int, kotlin.Int?>, kotlin.Int>) }
targetFunction = java/util/Comparator(block: kotlin.Function2<ft<kotlin.Int, kotlin.Int?>, ft<kotlin.Int, kotlin.Int?>, kotlin.Int>): java.util.Comparator<ft<kotlin.Int, kotlin.Int?>>
substitutor = <map substitutor: {FirTypeParameterSymbol T=ft<kotlin/Int, kotlin/Int?>}>
@@ -1,2 +1,2 @@
val c = java.util.<caret>Comparator {(x: Int, y: Int) -> 1}
val c = java.util.<caret>Comparator {x: Int, y: Int -> 1}
@@ -209,6 +209,7 @@ class FirSamResolverImpl(
isCrossinline = false
isNoinline = false
isVararg = false
resolvePhase = FirResolvePhase.BODY_RESOLVE
}
resolvePhase = FirResolvePhase.BODY_RESOLVE