KT-8176 References to type arguments are not resolved when number of them does not match type parameters
KT-8078 FQ-name inserted on class name completion in type arguments #KT-8176 Fixed #KT-8078 Fixed
This commit is contained in:
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
|
import org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
|
||||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||||
@@ -124,7 +123,8 @@ public class TypeResolver(
|
|||||||
|
|
||||||
val classifierDescriptor = resolveClass(c.scope, type, c.trace)
|
val classifierDescriptor = resolveClass(c.scope, type, c.trace)
|
||||||
if (classifierDescriptor == null) {
|
if (classifierDescriptor == null) {
|
||||||
resolveTypeProjections(c, ErrorUtils.createErrorType("No type").getConstructor(), type.getTypeArguments())
|
val arguments = resolveTypeProjections(c, ErrorUtils.createErrorType("No type").getConstructor(), type.getTypeArguments())
|
||||||
|
result = type(ErrorUtils.createErrorTypeWithArguments(type.getDebugText(), arguments))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ public class TypeResolver(
|
|||||||
val expectedArgumentCount = parameters.size()
|
val expectedArgumentCount = parameters.size()
|
||||||
val actualArgumentCount = arguments.size()
|
val actualArgumentCount = arguments.size()
|
||||||
if (ErrorUtils.isError(classifierDescriptor)) {
|
if (ErrorUtils.isError(classifierDescriptor)) {
|
||||||
result = type(ErrorUtils.createErrorType("[Error type: " + typeConstructor + "]"))
|
result = type(ErrorUtils.createErrorTypeWithArguments("[Error type: " + typeConstructor + "]", arguments))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (actualArgumentCount != expectedArgumentCount) {
|
if (actualArgumentCount != expectedArgumentCount) {
|
||||||
@@ -251,6 +251,13 @@ public class TypeResolver(
|
|||||||
c.trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet"))
|
c.trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (result != null && !result!!.isBare) {
|
||||||
|
for (argument in result!!.actualType.arguments) {
|
||||||
|
ForceResolveUtil.forceResolveAllContents(argument.type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result ?: type(ErrorUtils.createErrorType(typeElement?.getDebugText() ?: "No type element"))
|
return result ?: type(ErrorUtils.createErrorType(typeElement?.getDebugText() ?: "No type element"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class Foo<T, V>
|
||||||
|
|
||||||
|
class Bar: Foo<S<caret>
|
||||||
|
|
||||||
|
// ELEMENT: StringBuilder
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class Foo<T, V>
|
||||||
|
|
||||||
|
class Bar: Foo<StringBuilder<caret>
|
||||||
|
|
||||||
|
// ELEMENT: StringBuilder
|
||||||
+6
@@ -53,6 +53,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FirstTypeArgument.kt")
|
||||||
|
public void testFirstTypeArgument() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/FirstTypeArgument.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("GenericFunctionWithTab.kt")
|
@TestMetadata("GenericFunctionWithTab.kt")
|
||||||
public void testGenericFunctionWithTab() throws Exception {
|
public void testGenericFunctionWithTab() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/GenericFunctionWithTab.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/GenericFunctionWithTab.kt");
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
kotlin.Int
|
|
||||||
kotlin.properties.ObservableProperty
|
kotlin.properties.ObservableProperty
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
val v: UnknownClass<<caret>String>
|
||||||
|
|
||||||
|
// REF: (kotlin).String
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class Foo<T, V>
|
||||||
|
|
||||||
|
class Bar: Foo<<caret>String
|
||||||
|
|
||||||
|
// REF: (kotlin).String
|
||||||
@@ -353,6 +353,18 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("TypeArgumentUnresolvedClass.kt")
|
||||||
|
public void testTypeArgumentUnresolvedClass() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/TypeArgumentUnresolvedClass.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("TypeArgumentWrongNumber.kt")
|
||||||
|
public void testTypeArgumentWrongNumber() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/TypeArgumentWrongNumber.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TypeParameterInAnonymousObject.kt")
|
@TestMetadata("TypeParameterInAnonymousObject.kt")
|
||||||
public void testTypeParameterInAnonymousObject() throws Exception {
|
public void testTypeParameterInAnonymousObject() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/TypeParameterInAnonymousObject.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/TypeParameterInAnonymousObject.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user