[FIR] Introduce WRONG_NUMBER_OF_TYPE_ARGUMENTS diagnostic

This commit is contained in:
Mikhail Glukhikh
2020-07-27 12:53:38 +03:00
parent 0804c6a0f3
commit 551bdd267d
11 changed files with 17 additions and 13 deletions
@@ -86,8 +86,9 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect
EnumAsSupertype -> FirErrors.ENUM_AS_SUPERTYPE
RecursionInSupertypes -> FirErrors.RECURSION_IN_SUPERTYPES
RecursionInImplicitTypes -> FirErrors.RECURSION_IN_IMPLICIT_TYPES
SuperNotAllowed -> FirErrors.SUPER_IS_NOT_AN_EXPRESSION
Java -> FirErrors.ERROR_FROM_JAVA_RESOLUTION
SuperNotAllowed -> FirErrors.SUPER_IS_NOT_AN_EXPRESSION
WrongNumberOfTypeArguments -> FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS
ExpressionRequired -> FirErrors.EXPRESSION_REQUIRED
JumpOutsideLoop -> FirErrors.BREAK_OR_CONTINUE_OUTSIDE_A_LOOP
NotLoopLabel -> FirErrors.NOT_A_LOOP_LABEL
@@ -81,6 +81,7 @@ object FirErrors {
val PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT by error0<FirSourceElement, PsiElement>()
val UPPER_BOUND_VIOLATED by error0<FirSourceElement, PsiElement>()
val TYPE_ARGUMENTS_NOT_ALLOWED by error0<FirSourceElement, PsiElement>()
val WRONG_NUMBER_OF_TYPE_ARGUMENTS by error0<FirSourceElement, PsiElement>()
val MANY_COMPANION_OBJECTS by error0<FirSourceElement, PsiElement>()
val LOCAL_OBJECT_NOT_ALLOWED by error0<FirSourceElement, PsiElement>()
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.diagnostics.ConeIntermediateDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.diagnostics.ConeUnexpectedTypeArgumentsError
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.providers.bindSymbolToLookupTag
@@ -115,7 +116,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver {
if (n < 0) {
typeArguments = (1..symbol.fir.typeParameters.size).map {
ConeClassErrorType(
ConeSimpleDiagnostic("Type arguments number mismatch")
ConeSimpleDiagnostic("Type arguments number mismatch", DiagnosticKind.WrongNumberOfTypeArguments)
)
}.toTypedArray()
} else {
@@ -26,5 +26,6 @@ enum class DiagnosticKind {
RecursionInImplicitTypes,
Java,
SuperNotAllowed,
WrongNumberOfTypeArguments,
Other
}
@@ -11,7 +11,7 @@ interface B1<T : B0<*>>
interface AA<T: AA<*>>
interface BB<S : List<AA<*>>>
interface A<T: <!OTHER_ERROR!>List<T, T, T><!>>
interface A<T: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>List<T, T, T><!>>
class X<Y>
class D<T : X<in X<out X<T>>>>
@@ -32,5 +32,5 @@ fun test() {
fun <T: <!OTHER_ERROR!>Foo<String.Bar><!>> x() {}
fun Foo<String>.Bar.ext() {}
fun ex1(a: <!OTHER_ERROR!>Foo<String>.Bar<String><!>): <!OTHER_ERROR!>Foo<String>.Bar<String><!> {
fun ex1(a: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Foo<String>.Bar<String><!>): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Foo<String>.Bar<String><!> {
}
@@ -41,11 +41,11 @@ fun ok5(): test.Outer.Obj.Nested2<A>.Inner5<B> = null!!
fun errorTypeWithArguments(): <!OTHER_ERROR!>Q<A>.W<B, C, D>.R.M<!> = null!!
fun error1(): Outer<A>.Inner<B>.Inner3<C, D> = null!!
fun error2(): <!OTHER_ERROR!>Outer<A>.Inner<B, C, D>.Inner2<!> = null!!
fun error2(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Outer<A>.Inner<B, C, D>.Inner2<!> = null!!
fun error3(): <!OTHER_ERROR!>Outer.Inner<A, B>.Inner3<C><!> = null!!
fun error4(): <!OTHER_ERROR!>Outer<A>.Nested<B>.Inner4<C><!> = null!!
fun error5(): <!OTHER_ERROR!>Outer<A>.Obj.Nested2<B>.Inner5<C><!> = null!!
fun error6(): <!OTHER_ERROR!>Outer.Obj<A>.Nested2<B>.Inner5<C><!> = null!!
fun error4(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Outer<A>.Nested<B>.Inner4<C><!> = null!!
fun error5(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Outer<A>.Obj.Nested2<B>.Inner5<C><!> = null!!
fun error6(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Outer.Obj<A>.Nested2<B>.Inner5<C><!> = null!!
fun error7(): <!OTHER_ERROR!>test<String>.Outer.Obj.Nested2<A>.Inner5<B><!> = null!!
fun error7(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>test<String>.Outer.Obj.Nested2<A>.Inner5<B><!> = null!!
@@ -5,6 +5,6 @@ class OuterClass<T1> {
typealias NestedType<T> = NestedClass<T>
}
typealias ON1<T1, T2> = <!OTHER_ERROR!>OuterClass<T1>.NestedClass<T2><!>
typealias ON1<T1, T2> = <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>OuterClass<T1>.NestedClass<T2><!>
typealias ON2<T1, T2> = OuterClass<T1>.NestedType<T2>
typealias ON3<T2> = OuterClass.NestedType<T2>
@@ -46,5 +46,5 @@ interface Test<in I, out O, P> {
fun neOk32(i: <!OTHER_ERROR!>Inv<!>)
fun neOk33(i: Inv<<!SYNTAX!><!>>)
fun neOk34(i: <!OTHER_ERROR!>Inv<C><!>)
fun neOk35(i: <!OTHER_ERROR!>Inv<P, P><!>)
fun neOk35(i: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<P, P><!>)
}
@@ -43,5 +43,5 @@ interface Test<in I, out O, P> {
var neOk32: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Inv<!>
var neOk33: Inv<<!SYNTAX!><!>>
var neOk34: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Inv<C><!>
var neOk35: <!OTHER_ERROR, OTHER_ERROR, OTHER_ERROR!>Inv<P, P><!>
var neOk35: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS, WRONG_NUMBER_OF_TYPE_ARGUMENTS, WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<P, P><!>
}
@@ -38,5 +38,5 @@ interface Test<in I, out O, P> {
fun neOk32(): <!OTHER_ERROR!>Inv<!>
fun neOk33(): Inv<<!SYNTAX!><!>>
fun neOk34(): <!OTHER_ERROR!>Inv<C><!>
fun neOk35(): <!OTHER_ERROR!>Inv<P, P><!>
fun neOk35(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<P, P><!>
}