Smart completion should not suggest variants for private signatures

#KT-4899 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-04-30 19:53:24 +04:00
parent 57c41ce0b0
commit 5e34791e68
3 changed files with 26 additions and 1 deletions
@@ -49,6 +49,8 @@ import org.jetbrains.jet.plugin.completion.smart.isSubtypeOf
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall
import org.jetbrains.jet.lang.resolve.calls.util.noErrorsInValueArguments
import org.jetbrains.jet.lang.resolve.calls.util.hasUnmappedParameters
import org.jetbrains.jet.lang.descriptors.Visibilities
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorWithVisibility
enum class Tail {
COMMA
@@ -131,7 +133,10 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
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())) {
val parameters = candidate.getResultingDescriptor().getValueParameters()
val descriptor = candidate.getResultingDescriptor()
if (!Visibilities.isVisible(descriptor, resolutionScope.getContainingDeclaration())) continue
val parameters = descriptor.getValueParameters()
if (isFunctionLiteralArgument) {
if (argumentIndex != parameters.size - 1) continue
}
@@ -0,0 +1,15 @@
fun f(p1: Any, p2: String, p3: Int) {
C().foo(<caret>)
}
class C {
public fun foo(p1: String, p2: Any) {
}
private fun foo(p1: Int) {
}
}
// ABSENT: p1
// EXIST: p2
// ABSENT: p3
@@ -301,6 +301,11 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
doTest("idea/testData/completion/smart/NoNothing.kt");
}
@TestMetadata("NoPrivateOverload.kt")
public void testNoPrivateOverload() throws Exception {
doTest("idea/testData/completion/smart/NoPrivateOverload.kt");
}
@TestMetadata("NoSillyAssignment.kt")
public void testNoSillyAssignment() throws Exception {
doTest("idea/testData/completion/smart/NoSillyAssignment.kt");