Simplify diagnostic when there are wrong number of type arguments

#KT-12767 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-07-10 18:43:02 +03:00
parent e82c909f75
commit ee173077c0
15 changed files with 36 additions and 16 deletions
@@ -747,7 +747,7 @@ public class DefaultErrorMessages {
MAP.put(TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT, "Type inference for control flow expression failed. Please specify its type explicitly.");
String wrongNumberOfTypeArguments = "{0,choice,0#No type arguments|1#One type argument|1<{0,number,integer} type arguments} expected";
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, wrongNumberOfTypeArguments + " for {1}", null, WITHOUT_MODIFIERS);
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, wrongNumberOfTypeArguments + " for {1}", null, COMPACT_WITHOUT_SUPERTYPES);
MAP.put(
OUTER_CLASS_ARGUMENTS_REQUIRED,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -511,6 +511,7 @@ object Renderers {
@JvmField val FQ_NAMES_IN_TYPES = DescriptorRenderer.FQ_NAMES_IN_TYPES.asRenderer()
@JvmField val COMPACT = DescriptorRenderer.COMPACT.asRenderer()
@JvmField val COMPACT_WITHOUT_SUPERTYPES = DescriptorRenderer.COMPACT_WITHOUT_SUPERTYPES.asRenderer()
@JvmField val WITHOUT_MODIFIERS = DescriptorRenderer.withOptions {
modifiers = emptySet()
}.asRenderer()
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -106,6 +106,12 @@ abstract class DescriptorRenderer {
modifiers = emptySet()
}
@JvmField val COMPACT_WITHOUT_SUPERTYPES: DescriptorRenderer = withOptions {
withDefinedIn = false
modifiers = emptySet()
withoutSuperTypes = true
}
@JvmField val COMPACT_WITH_SHORT_TYPES: DescriptorRenderer = withOptions {
modifiers = emptySet()
classifierNamePolicy = ClassifierNamePolicy.SHORT
@@ -1,3 +1,3 @@
interface ApplicationFeature<in P : Pipeline<*>, B : Any, V>
open class Pipeline<TSubject : Any>()
fun <A : Pipeline<*>, T : Any, V> A.feature(<warning>feature</warning>: ApplicationFeature<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] 3 type arguments expected for interface ApplicationFeature<in P : Pipeline<*>, B : Any, V> defined in root package in file incompleteTypeArgumentList.kt"><A, T></error>) : Unit {}
fun <A : Pipeline<*>, T : Any, V> A.feature(<warning>feature</warning>: ApplicationFeature<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] 3 type arguments expected for interface ApplicationFeature<in P : Pipeline<*>, B : Any, V>"><A, T></error>) : Unit {}
@@ -0,0 +1,7 @@
package name.that.may.be.very.long
import java.io.Serializable
interface Foo<T> : Comparable<Foo<T>>, Serializable, Cloneable
fun test(<warning>f</warning>: <error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for interface Foo<T>">Foo</error>) {}
+1 -1
View File
@@ -2,4 +2,4 @@ open class A<T>()
class G<T>()
class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T> defined in root package in file kt9887.kt">G</error>>()
class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T>">G</error>>()
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddStarProjectionsFix" "false"
// ERROR: 2 type arguments expected for interface Map<K, out V> defined in kotlin.collections
// ERROR: 2 type arguments expected for interface Map<K, out V>
public fun foo(a: Any) {
a is <caret>Map<Int>
}
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddStarProjectionsFix" "false"
// ERROR: 2 type arguments expected for interface Map<K, out V> defined in kotlin.collections
// ERROR: 2 type arguments expected for interface Map<K, out V>
public fun foo(a: Any) {
when (a) {
is <caret>Map<Int> -> {}
@@ -1,7 +1,7 @@
// "Create secondary constructor" "false"
// ACTION: Add parameter to constructor 'A'
// ACTION: Create function 'A'
// ERROR: No type arguments expected for constructor A() defined in A
// ERROR: No type arguments expected for constructor A()
// ERROR: Too many arguments for public constructor A() defined in A
class A
@@ -1,4 +1,4 @@
// "Create type parameter in class 'X'" "false"
// ERROR: 2 type arguments expected for class X<T, U> defined in root package in file missingArguments.kt
// ERROR: 2 type arguments expected for class X<T, U>
class X<T, U>
fun Y(x: X<<caret>String>) {}
@@ -1,5 +1,5 @@
// "Create type parameter in class 'X'" "false"
// ERROR: No type arguments expected for class X defined in root package in file notOnTypeArgumentList.kt
// ERROR: No type arguments expected for class X
class X
+1 -1
View File
@@ -1,6 +1,6 @@
// "Make 'IterablePipeline' abstract" "true"
// ERROR: 'pipe' overrides nothing
// ERROR: One type argument expected for interface Pipeline<TPipeline> defined in root package in file kt10409.kt
// ERROR: One type argument expected for interface Pipeline<TPipeline>
// Actually this test is about getting rid of assertion happenning while creating quick fixes
// See KT-10409
+1 -1
View File
@@ -1,6 +1,6 @@
// "Make 'IterablePipeline' abstract" "true"
// ERROR: 'pipe' overrides nothing
// ERROR: One type argument expected for interface Pipeline<TPipeline> defined in root package in file kt10409.kt
// ERROR: One type argument expected for interface Pipeline<TPipeline>
// Actually this test is about getting rid of assertion happenning while creating quick fixes
// See KT-10409
@@ -998,6 +998,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
doTest(fileName);
}
@TestMetadata("nArgumentsExpectedMessage.kt")
public void testNArgumentsExpectedMessage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/diagnosticsMessage/nArgumentsExpectedMessage.kt");
doTest(fileName);
}
@TestMetadata("noSubstitutedTypeParameter.kt")
public void testNoSubstitutedTypeParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.kt");
@@ -51,16 +51,16 @@ End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
One type argument expected for class A<T> defined in foo
One type argument expected for class A<T> defined in foo
One type argument expected for class A<T> defined in foo
One type argument expected for class A<T>
One type argument expected for class A<T>
One type argument expected for class A<T>
Type inference failed: Not enough information to infer parameter T in constructor A<T>()
Please specify it explicitly.
Type inference failed: Not enough information to infer parameter T in constructor A<T>()
Please specify it explicitly.
Type inference failed: Not enough information to infer parameter T in constructor A<T>()
Please specify it explicitly.
One type argument expected for class A<T> defined in foo
One type argument expected for class A<T>
================ Step #2 =================