Fixed KT-3807 Wrong completion for class/trait with extesion function
#KT-3807 Fixed
This commit is contained in:
committed by
valentin
parent
e30998d3c1
commit
94c9338e3c
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils
|
|||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
||||||
|
import org.jetbrains.jet.lang.resolve.descriptorUtil.isExtension
|
||||||
|
|
||||||
public object TipsManager{
|
public object TipsManager{
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ public object TipsManager{
|
|||||||
val dataFlowInfo = context.getDataFlowInfo(expression)
|
val dataFlowInfo = context.getDataFlowInfo(expression)
|
||||||
|
|
||||||
for (variant in AutoCastUtils.getAutoCastVariants(receiverValue, context, dataFlowInfo)) {
|
for (variant in AutoCastUtils.getAutoCastVariants(receiverValue, context, dataFlowInfo)) {
|
||||||
variant.getMemberScope().getAllDescriptors().filterTo(descriptors, ::filterIfInfix)
|
variant.getMemberScope().getAllDescriptors().filterTo(descriptors) { filterIfInfix(it) && !it.isExtension }
|
||||||
}
|
}
|
||||||
|
|
||||||
JetScopeUtils.getAllExtensions(resolutionScope).filterTo(descriptors) {
|
JetScopeUtils.getAllExtensions(resolutionScope).filterTo(descriptors) {
|
||||||
@@ -77,9 +78,7 @@ public object TipsManager{
|
|||||||
val descriptorsSet = HashSet<DeclarationDescriptor>()
|
val descriptorsSet = HashSet<DeclarationDescriptor>()
|
||||||
|
|
||||||
for (receiverDescriptor in resolutionScope.getImplicitReceiversHierarchy()) {
|
for (receiverDescriptor in resolutionScope.getImplicitReceiversHierarchy()) {
|
||||||
receiverDescriptor.getType().getMemberScope().getAllDescriptors().filterTo(descriptorsSet) {
|
receiverDescriptor.getType().getMemberScope().getAllDescriptors().filterTo(descriptorsSet) { !it.isExtension }
|
||||||
it !is CallableDescriptor || it.getReceiverParameter() == null/*skip member extension functions and properties*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptorsSet.addAll(resolutionScope.getAllDescriptors())
|
descriptorsSet.addAll(resolutionScope.getAllDescriptors())
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.psi.JetExpression
|
|||||||
import org.jetbrains.jet.plugin.completion.ExpectedInfo
|
import org.jetbrains.jet.plugin.completion.ExpectedInfo
|
||||||
import org.jetbrains.jet.plugin.util.makeNotNullable
|
import org.jetbrains.jet.plugin.util.makeNotNullable
|
||||||
import org.jetbrains.jet.plugin.completion.qualifiedNameForSourceCode
|
import org.jetbrains.jet.plugin.completion.qualifiedNameForSourceCode
|
||||||
|
import org.jetbrains.jet.lang.resolve.descriptorUtil.isExtension
|
||||||
|
|
||||||
// adds java static members, enum members and members from class object
|
// adds java static members, enum members and members from class object
|
||||||
class StaticMembers(val bindingContext: BindingContext, val resolveSession: ResolveSessionForBodies) {
|
class StaticMembers(val bindingContext: BindingContext, val resolveSession: ResolveSessionForBodies) {
|
||||||
@@ -93,7 +94,7 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
|
|||||||
val classObject = classDescriptor.getClassObjectDescriptor()
|
val classObject = classDescriptor.getClassObjectDescriptor()
|
||||||
if (classObject != null) {
|
if (classObject != null) {
|
||||||
classObject.getDefaultType().getMemberScope().getAllDescriptors()
|
classObject.getDefaultType().getMemberScope().getAllDescriptors()
|
||||||
.filter { it !is CallableDescriptor || it.getReceiverParameter() == null }
|
.filter { !it.isExtension }
|
||||||
.forEach(::processMember)
|
.forEach(::processMember)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class Foo {
|
||||||
|
fun Int.bar() = this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val v = Foo()
|
||||||
|
v.<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ABSENT: bar
|
||||||
@@ -17,13 +17,10 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -620,6 +617,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongExplicitReceiver.kt")
|
||||||
|
public void testWrongExplicitReceiver() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongImplicitReceiver.kt")
|
@TestMetadata("WrongImplicitReceiver.kt")
|
||||||
public void testWrongImplicitReceiver() throws Exception {
|
public void testWrongImplicitReceiver() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongImplicitReceiver.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongImplicitReceiver.kt");
|
||||||
|
|||||||
@@ -17,13 +17,10 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -620,6 +617,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongExplicitReceiver.kt")
|
||||||
|
public void testWrongExplicitReceiver() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongExplicitReceiver.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("WrongImplicitReceiver.kt")
|
@TestMetadata("WrongImplicitReceiver.kt")
|
||||||
public void testWrongImplicitReceiver() throws Exception {
|
public void testWrongImplicitReceiver() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongImplicitReceiver.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/basic/common/extensions/WrongImplicitReceiver.kt");
|
||||||
|
|||||||
@@ -17,9 +17,13 @@
|
|||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import junit.framework.TestSuite;
|
||||||
import org.junit.runner.RunWith;
|
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.io.File;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|||||||
Reference in New Issue
Block a user