[FIR] Check that expected lambda type is extension function using cone expected type
#KT-41991 In progress
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
// ISSUE: KT-41991
|
||||
|
||||
fun runLambdas(vararg values: String.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
runLambdas({
|
||||
length
|
||||
})
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
FILE: varargOfLambdasWithReceiver.kt
|
||||
public final fun runLambdas(vararg values: @R|kotlin/ExtensionFunctionType|() R|kotlin/Array<out @ExtensionFunctionType kotlin/Function1<kotlin/String, kotlin/Unit>>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/runLambdas|(vararg(runLambdas@fun R|kotlin/String|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|kotlin/String.length|
|
||||
}
|
||||
))
|
||||
}
|
||||
Generated
+5
@@ -575,6 +575,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargOfLambdasWithReceiver.kt")
|
||||
public void testVarargOfLambdasWithReceiver() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/varargOfLambdasWithReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargProjection.kt")
|
||||
public void testVarargProjection() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/varargProjection.kt");
|
||||
|
||||
+5
@@ -575,6 +575,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargOfLambdasWithReceiver.kt")
|
||||
public void testVarargOfLambdasWithReceiver() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/varargOfLambdasWithReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargProjection.kt")
|
||||
public void testVarargProjection() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/arguments/varargProjection.kt");
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ fun ConeKotlinType.isKFunctionType(session: FirSession): Boolean {
|
||||
}
|
||||
|
||||
fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef?, session: FirSession): ConeKotlinType? {
|
||||
if (isBuiltinFunctionalType(session) && expectedTypeRef?.isExtensionFunctionType(session) == true) {
|
||||
if (isBuiltinFunctionalType(session) && isExtensionFunctionType(session)) {
|
||||
return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type
|
||||
}
|
||||
return null
|
||||
@@ -99,7 +99,7 @@ fun extractLambdaInfoFromFunctionalType(
|
||||
|
||||
val receiverType = argument.receiverType ?: expectedType.receiverType(expectedTypeRef, session)
|
||||
val returnType = argument.returnType ?: expectedType.returnType(session) ?: return null
|
||||
val parameters = extractLambdaParameters(expectedType, argument, expectedTypeRef?.isExtensionFunctionType(session) ?: false, session)
|
||||
val parameters = extractLambdaParameters(expectedType, argument, expectedType.isExtensionFunctionType(session), session)
|
||||
|
||||
return ResolvedLambdaAtom(
|
||||
argument,
|
||||
|
||||
Reference in New Issue
Block a user