Fixed: analyze unmapped (or with no callee) functional arguments with right context.
This commit is contained in:
+6
-10
@@ -20,7 +20,6 @@ import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -29,8 +28,6 @@ import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstantResolver;
|
||||
import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
||||
@@ -46,7 +43,6 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.getRecordedTypeInfo;
|
||||
@@ -97,7 +93,7 @@ public class ArgumentTypeResolver {
|
||||
for (ValueArgument valueArgument : context.call.getValueArguments()) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null && !(argumentExpression instanceof JetFunctionLiteralExpression)) {
|
||||
checkArgumentType(context, argumentExpression);
|
||||
checkArgumentTypeWithNoCallee(context, argumentExpression);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,12 +118,12 @@ public class ArgumentTypeResolver {
|
||||
for (ValueArgument valueArgument : context.call.getValueArguments()) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null && (argumentExpression instanceof JetFunctionLiteralExpression)) {
|
||||
checkArgumentType(context, argumentExpression);
|
||||
checkArgumentTypeWithNoCallee(context, argumentExpression);
|
||||
}
|
||||
}
|
||||
|
||||
for (JetExpression expression : context.call.getFunctionLiteralArguments()) {
|
||||
checkArgumentType(context, expression);
|
||||
checkArgumentTypeWithNoCallee(context, expression);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,13 +131,13 @@ public class ArgumentTypeResolver {
|
||||
for (ValueArgument valueArgument : unmappedArguments) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null) {
|
||||
checkArgumentType(context, argumentExpression);
|
||||
checkArgumentTypeWithNoCallee(context, argumentExpression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkArgumentType(CallResolutionContext<?> context, JetExpression argumentExpression) {
|
||||
expressionTypingServices.getType(context.scope, argumentExpression, NO_EXPECTED_TYPE, context.dataFlowInfo, context.trace);
|
||||
private void checkArgumentTypeWithNoCallee(CallResolutionContext<?> context, JetExpression argumentExpression) {
|
||||
expressionTypingServices.getTypeInfo(argumentExpression, context.replaceExpectedType(NO_EXPECTED_TYPE));
|
||||
updateResultArgumentTypeIfNotDenotable(context, argumentExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package c
|
||||
|
||||
fun test() {
|
||||
with (1) @l {
|
||||
foo(1, <!NAMED_PARAMETER_NOT_FOUND!>zz<!> = { this@l } )
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(x: Int) = x
|
||||
|
||||
// from library
|
||||
fun <T, R> with(receiver: T, f: T.() -> R) : R = receiver.f()
|
||||
@@ -5388,6 +5388,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/resolve/nestedCalls/analyzeArgsInFreeExpressionPosition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("analyzeUnmappedArguments.kt")
|
||||
public void testAnalyzeUnmappedArguments() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/resolve/nestedCalls/analyzeUnmappedArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("completeUnmappedArguments.kt")
|
||||
public void testCompleteUnmappedArguments() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/resolve/nestedCalls/completeUnmappedArguments.kt");
|
||||
|
||||
Reference in New Issue
Block a user