[FIR] Enable arrayOf transformer in completion (inside annotations)
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
FILE: main.kt
|
FILE: main.kt
|
||||||
@R|Ann|(vararg(String(a), String(b))) public final fun test_1(): R|kotlin/Unit| {
|
@R|Ann|(vararg(String(a), String(b))) public final fun test_1(): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
@R|Ann|(R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(a), String(b)))) public final fun test_2(): R|kotlin/Unit| {
|
@R|Ann|(<implicitArrayOf>(String(a), String(b))) public final fun test_2(): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
@R|Ann|(vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(a), String(b))))) public final fun test_3(): R|kotlin/Unit| {
|
@R|Ann|(vararg(*<implicitArrayOf>(String(a), String(b)))) public final fun test_3(): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType
|
|||||||
import org.jetbrains.kotlin.fir.resolve.inference.returnType
|
import org.jetbrains.kotlin.fir.resolve.inference.returnType
|
||||||
import org.jetbrains.kotlin.fir.resolve.propagateTypeFromQualifiedAccessAfterNullCheck
|
import org.jetbrains.kotlin.fir.resolve.propagateTypeFromQualifiedAccessAfterNullCheck
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirArrayOfCallTransformer
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.remapArgumentsWithVararg
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.remapArgumentsWithVararg
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall
|
import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall
|
||||||
@@ -50,10 +51,22 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
|
|
||||||
private val declarationWriter by lazy { FirDeclarationCompletionResultsWriter(finalSubstitutor) }
|
private val declarationWriter by lazy { FirDeclarationCompletionResultsWriter(finalSubstitutor) }
|
||||||
|
|
||||||
|
private val arrayOfCallTransformer = FirArrayOfCallTransformer()
|
||||||
|
private var enableArrayOfCallTransformation = false
|
||||||
|
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
Normal, DelegatedPropertyCompletion
|
Normal, DelegatedPropertyCompletion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inline fun <T> withFirArrayOfCallTransformer(block: () -> T): T {
|
||||||
|
enableArrayOfCallTransformation = true
|
||||||
|
return try {
|
||||||
|
block()
|
||||||
|
} finally {
|
||||||
|
enableArrayOfCallTransformation = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun <T : FirQualifiedAccessExpression> prepareQualifiedTransform(
|
private fun <T : FirQualifiedAccessExpression> prepareQualifiedTransform(
|
||||||
qualifiedAccessExpression: T, calleeReference: FirNamedReferenceWithCandidate
|
qualifiedAccessExpression: T, calleeReference: FirNamedReferenceWithCandidate
|
||||||
): T {
|
): T {
|
||||||
@@ -167,6 +180,12 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
result.transformExplicitReceiver(typeUpdater, null)
|
result.transformExplicitReceiver(typeUpdater, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableArrayOfCallTransformation) {
|
||||||
|
arrayOfCallTransformer.toArrayOfCall(result)?.let {
|
||||||
|
return it.compose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result.compose()
|
return result.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +201,13 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
)
|
)
|
||||||
val subCandidate = calleeReference.candidate
|
val subCandidate = calleeReference.candidate
|
||||||
val expectedArgumentsTypeMapping = runIf(!calleeReference.isError) { subCandidate.createArgumentsMapping() }
|
val expectedArgumentsTypeMapping = runIf(!calleeReference.isError) { subCandidate.createArgumentsMapping() }
|
||||||
annotationCall.argumentList.transformArguments(this, expectedArgumentsTypeMapping)
|
withFirArrayOfCallTransformer {
|
||||||
|
annotationCall.argumentList.transformArguments(this, expectedArgumentsTypeMapping)
|
||||||
|
var index = 0
|
||||||
|
subCandidate.argumentMapping = subCandidate.argumentMapping?.mapKeys { (_, _) ->
|
||||||
|
annotationCall.argumentList.arguments[index++]
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!calleeReference.isError) {
|
if (!calleeReference.isError) {
|
||||||
subCandidate.handleVarargs(annotationCall.argumentList)
|
subCandidate.handleVarargs(annotationCall.argumentList)
|
||||||
subCandidate.argumentMapping?.let {
|
subCandidate.argumentMapping?.let {
|
||||||
|
|||||||
Reference in New Issue
Block a user