Fixed KT-9496 FQ-class name inserted in type argument on copy/paste

#KT-9496 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-10-12 21:12:33 +03:00
parent f4e1f53549
commit d728417f7f
11 changed files with 60 additions and 11 deletions
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.*;
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors;
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage;
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
@@ -558,6 +559,21 @@ public class CallResolver {
if (context.checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS) {
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context);
}
List<JetTypeProjection> typeArguments = context.call.getTypeArguments();
for (JetTypeProjection projection : typeArguments) {
if (projection.getProjectionKind() != JetProjectionKind.NONE) {
context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection));
ModifierCheckerCore.INSTANCE.check(projection, context.trace, null);
}
JetType type = argumentTypeResolver.resolveTypeRefWithDefault(
projection.getTypeReference(), context.scope, context.trace,
null);
if (type != null) {
ForceResolveUtil.forceResolveAllContents(type);
}
}
Collection<ResolvedCall<F>> allCandidates = Lists.newArrayList();
OverloadResolutionResultsImpl<F> successfulResults = null;
TemporaryBindingTrace traceForFirstNonemptyCandidateSet = null;
@@ -21,7 +21,6 @@ import com.google.common.collect.Sets
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.ReflectionTypes
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT
import org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.*
@@ -46,7 +45,6 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask
import org.jetbrains.kotlin.resolve.calls.tasks.isSynthesizedInvoke
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.types.*
@@ -118,16 +116,11 @@ public class CandidateResolver(
val typeArguments = ArrayList<JetType>()
for (projection in jetTypeArguments) {
if (projection.getProjectionKind() != JetProjectionKind.NONE) {
trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection))
ModifierCheckerCore.check(projection, trace, null)
}
val type = argumentTypeResolver.resolveTypeRefWithDefault(
projection.getTypeReference(), scope, trace,
ErrorUtils.createErrorType("Star projection in a call"))!!
ForceResolveUtil.forceResolveAllContents(type)
val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) }
?: ErrorUtils.createErrorType("Star projection in a call")
typeArguments.add(type)
}
val expectedTypeArgumentCount = candidateDescriptor.getTypeParameters().size()
for (index in jetTypeArguments.size()..expectedTypeArgumentCount - 1) {
typeArguments.add(ErrorUtils.createErrorType(
@@ -5,7 +5,7 @@ fun foo(<!UNUSED_PARAMETER!>a<!> : Any?) {}
public fun main() {
getT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
<!UNRESOLVED_REFERENCE!>ggetT<!><<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
<!UNRESOLVED_REFERENCE!>ggetT<!><<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
getTT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
getTT<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, Int>()
getTT<Int, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
@@ -0,0 +1,4 @@
fun foo() {
<!UNRESOLVED_REFERENCE!>x<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>yyy<!><<!UNRESOLVED_REFERENCE!>XXX<!>>()
<!UNRESOLVED_REFERENCE!>x<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>yyy<!><Int>()
}
@@ -0,0 +1,3 @@
package
public fun foo(): kotlin.Unit
@@ -12603,6 +12603,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("resolveTypeArgsForUnresolvedCall.kt")
public void testResolveTypeArgsForUnresolvedCall() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/resolveTypeArgsForUnresolvedCall.kt");
doTest(fileName);
}
@TestMetadata("resolveWithFunctionLiteralWithId.kt")
public void testResolveWithFunctionLiteralWithId() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralWithId.kt");
@@ -0,0 +1,6 @@
// ERROR: Unresolved reference: list
import java.io.File
fun file() {
list.filterIsInstance<File>()
}
@@ -0,0 +1 @@
java.io.File
@@ -0,0 +1,5 @@
import java.io.File
fun file(list: List<Any>) {
<selection>list.filterIsInstance<File>()</selection>
}
@@ -0,0 +1,3 @@
fun file() {
<caret>
}
@@ -361,6 +361,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
doTestCopy(fileName);
}
@TestMetadata("TypeArgForUnresolvedCall.kt")
public void testTypeArgForUnresolvedCall() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/TypeArgForUnresolvedCall.kt");
doTestCopy(fileName);
}
@TestMetadata("TypeParameter.kt")
public void testTypeParameter() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/TypeParameter.kt");
@@ -700,6 +706,12 @@ public class InsertImportOnPasteTestGenerated extends AbstractInsertImportOnPast
doTestCut(fileName);
}
@TestMetadata("TypeArgForUnresolvedCall.kt")
public void testTypeArgForUnresolvedCall() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/TypeArgForUnresolvedCall.kt");
doTestCut(fileName);
}
@TestMetadata("TypeParameter.kt")
public void testTypeParameter() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/copyPaste/imports/TypeParameter.kt");