Do not add receiver for function expression by expected type.
This commit is contained in:
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.getReceiverTypeFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl
|
||||
@@ -152,10 +149,12 @@ class FunctionDescriptorResolver(
|
||||
|
||||
val receiverTypeRef = function.receiverTypeReference
|
||||
val receiverType =
|
||||
if (receiverTypeRef != null)
|
||||
if (receiverTypeRef != null) {
|
||||
typeResolver.resolveType(innerScope, receiverTypeRef, trace, true)
|
||||
else
|
||||
expectedFunctionType.getReceiverType()
|
||||
}
|
||||
else {
|
||||
if (function is KtFunctionLiteral) expectedFunctionType.getReceiverType() else null
|
||||
}
|
||||
|
||||
|
||||
val valueParameterDescriptors = createValueParameterDescriptors(function, functionDescriptor, innerScope, trace, expectedFunctionType)
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
fun foo(<!UNUSED_PARAMETER!>f<!>: String.() -> Int) {}
|
||||
val test = foo(<!TYPE_MISMATCH(String.\(\) -> Int; \(\) -> [ERROR : Error function type])!>fun () = <!UNRESOLVED_REFERENCE!>length<!><!>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public val test: kotlin.Unit
|
||||
public fun foo(/*0*/ f: kotlin.String.() -> kotlin.Int): kotlin.Unit
|
||||
@@ -7161,6 +7161,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReceiverByExpectedType.kt")
|
||||
public void testReceiverByExpectedType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionAsExpression/ReceiverByExpectedType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ReturnAndLabels.kt")
|
||||
public void testReturnAndLabels() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionAsExpression/ReturnAndLabels.kt");
|
||||
|
||||
Reference in New Issue
Block a user