Fixed smart completion not working when parameter has default value

This commit is contained in:
Valentin Kipyatkov
2014-09-29 18:29:08 +04:00
parent 267aabae12
commit 35ebbab733
3 changed files with 20 additions and 3 deletions
@@ -167,7 +167,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val resolveSession: Reso
val expectedInfos = HashSet<ExpectedInfo>()
for (candidate: ResolvedCall<FunctionDescriptor> in results.getAllCandidates()!!) {
// consider only candidates with more arguments than in the truncated call and with all arguments before the current one matched
if (candidate.noErrorsInValueArguments() && (isFunctionLiteralArgument || candidate.hasUnmappedParameters())) {
if (candidate.noErrorsInValueArguments() && (candidate.getCandidateDescriptor().getValueParameters().size > argumentIndex || isFunctionLiteralArgument)) {
val descriptor = candidate.getResultingDescriptor()
if (!Visibilities.isVisible(descriptor, resolutionScope.getContainingDeclaration())) continue
@@ -0,0 +1,7 @@
fun foo(p1: String, p2: String = "") { }
fun bar(s: String) {
foo("", <caret>)
}
// EXIST: s
@@ -17,9 +17,13 @@
package org.jetbrains.jet.completion;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.TestMetadata;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.RunWith;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.JUnit3RunnerWithInners;
import java.io.File;
import java.util.regex.Pattern;
@@ -604,6 +608,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
doTest(fileName);
}
@TestMetadata("ParameterWithDefaultValue.kt")
public void testParameterWithDefaultValue() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smart/ParameterWithDefaultValue.kt");
doTest(fileName);
}
@TestMetadata("PrivateConstructorForAbstract.kt")
public void testPrivateConstructorForAbstract() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/smart/PrivateConstructorForAbstract.kt");