KT-13780 No completion and assertion error in log
#KT-13780 Fixed
This commit is contained in:
+1
-1
@@ -153,7 +153,7 @@ class LookupElementFactory(
|
||||
//TODO: order for them
|
||||
val fuzzyParameterType = parameterType.toFuzzyType(descriptor.typeParameters)
|
||||
for ((variable, substitutor) in contextVariablesProvider.functionTypeVariables(fuzzyParameterType)) {
|
||||
val substitutedDescriptor = descriptor.substitute(substitutor)
|
||||
val substitutedDescriptor = descriptor.substitute(substitutor) ?: continue
|
||||
add(createFunctionCallElementWithArguments(substitutedDescriptor, variable.name.render(), useReceiverTypes))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ class TypeInstantiationItems(
|
||||
1 -> {
|
||||
val constructor = visibleConstructors.single()
|
||||
val substitutor = TypeSubstitutor.create(fuzzyType.presentationType())
|
||||
val substitutedConstructor = constructor.substitute(substitutor)
|
||||
val substitutedConstructor = constructor.substitute(substitutor) ?: constructor // render original signature if failed to substitute
|
||||
BasicLookupElementFactory.SHORT_NAMES_RENDERER.renderFunctionParameters(substitutedConstructor)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class ResolvedCall<out D>(val candidateDescriptor: D)
|
||||
|
||||
fun test(myResolvedCall: ResolvedCall<String>) {
|
||||
bar(my<caret>)
|
||||
}
|
||||
|
||||
fun bar(foo: ResolvedCall<*>) {}
|
||||
|
||||
// EXIST: myResolvedCall
|
||||
@@ -0,0 +1,9 @@
|
||||
class ResolvedCall<out D>(val candidateDescriptor: D)
|
||||
|
||||
fun test(myResolvedCall: ResolvedCall<Any>) {
|
||||
bar(my<caret>)
|
||||
}
|
||||
|
||||
fun bar(foo: ResolvedCall<out CharSequence>) {}
|
||||
|
||||
// EXIST: myResolvedCall
|
||||
@@ -0,0 +1,9 @@
|
||||
class X<D>()
|
||||
|
||||
fun test() {
|
||||
bar(<caret>)
|
||||
}
|
||||
|
||||
fun bar(foo: X<*>) {}
|
||||
|
||||
// EXIST: { lookupString:"X", itemText:"X", tailText:"() (<root>)" }
|
||||
@@ -0,0 +1,9 @@
|
||||
class X<D>(d: D)
|
||||
|
||||
fun test() {
|
||||
bar(<caret>)
|
||||
}
|
||||
|
||||
fun bar(foo: X<*>) {}
|
||||
|
||||
// EXIST: { lookupString:"X", itemText:"X", tailText:"(d: D) (<root>)" }
|
||||
+12
@@ -493,6 +493,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT13780.kt")
|
||||
public void testKT13780() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/KT13780.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT13780_1.kt")
|
||||
public void testKT13780_1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LocalMultideclarationValues.kt")
|
||||
public void testLocalMultideclarationValues() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/LocalMultideclarationValues.kt");
|
||||
|
||||
+12
@@ -493,6 +493,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT13780.kt")
|
||||
public void testKT13780() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/KT13780.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("KT13780_1.kt")
|
||||
public void testKT13780_1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/KT13780_1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LocalMultideclarationValues.kt")
|
||||
public void testLocalMultideclarationValues() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/LocalMultideclarationValues.kt");
|
||||
|
||||
+12
@@ -874,6 +874,18 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("StarProjection1.kt")
|
||||
public void testStarProjection1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/constructor/StarProjection1.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("StarProjection2.kt")
|
||||
public void testStarProjection2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/constructor/StarProjection2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("WithParameters.kt")
|
||||
public void testWithParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/constructor/WithParameters.kt");
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeNullability
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.util.isValidOperator
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
abstract class TypesWithOperatorDetector(
|
||||
@@ -70,7 +71,7 @@ abstract class TypesWithOperatorDetector(
|
||||
}
|
||||
|
||||
val substitutor = checkIsSuitableByType(function, freeParameters) ?: continue
|
||||
add(function.substitute(substitutor))
|
||||
addIfNotNull(function.substitute(substitutor))
|
||||
}
|
||||
return this
|
||||
}
|
||||
@@ -90,18 +91,17 @@ abstract class TypesWithOperatorDetector(
|
||||
if (type.nullability() != TypeNullability.NULLABLE) {
|
||||
for (memberFunction in type.type.memberScope.getContributedFunctions(name, NoLookupLocation.FROM_IDE)) {
|
||||
if (memberFunction.isValidOperator()) {
|
||||
checkIsSuitableByType(memberFunction, type.freeParameters)?.let { substitutor ->
|
||||
return Pair(memberFunction.substitute(substitutor), substitutor)
|
||||
}
|
||||
val substitutor = checkIsSuitableByType(memberFunction, type.freeParameters) ?: continue
|
||||
val substituted = memberFunction.substitute(substitutor) ?: continue
|
||||
return substituted to substitutor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (operator in extensionOperators) {
|
||||
val substitutor = type.checkIsSubtypeOf(operator.fuzzyExtensionReceiverType()!!)
|
||||
if (substitutor != null) {
|
||||
return Pair(operator.substitute(substitutor), substitutor)
|
||||
}
|
||||
val substitutor = type.checkIsSubtypeOf(operator.fuzzyExtensionReceiverType()!!) ?: continue
|
||||
val substituted = operator.substitute(substitutor) ?: continue
|
||||
return substituted to substitutor
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
@@ -29,11 +29,11 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.isVisible
|
||||
import org.jetbrains.kotlin.idea.core.moveCaret
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
@@ -72,7 +72,7 @@ object SuperClassNotInitialized : KotlinIntentionActionsFactory() {
|
||||
|
||||
val substitutedConstructors = constructors
|
||||
.filter { it.valueParameters.isNotEmpty() }
|
||||
.map { it.substitute(substitutor) }
|
||||
.mapNotNull { it.substitute(substitutor) }
|
||||
|
||||
if (substitutedConstructors.isNotEmpty()) {
|
||||
val parameterTypes: List<List<KotlinType>> = substitutedConstructors.map {
|
||||
|
||||
Reference in New Issue
Block a user