From 2e4daee1d460665381f6243094a2ad6d19e202b8 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Mon, 18 Jan 2021 22:39:41 +0300 Subject: [PATCH] [FIR] Fix invalid diagnostic fir node sites and improved invalid type parameters count diagnostic report --- .../typeArgumentsNotAllowed.fir.txt | 8 +++---- .../diagnostics/upperBoundViolated.fir.txt | 2 +- .../resolve/diagnostics/upperBoundViolated.kt | 2 +- .../resolve/typeParameterVsNested.fir.txt | 8 +++---- .../testData/resolve/typeParameterVsNested.kt | 4 ++-- .../capturedParametersOfInnerClasses.fir.txt | 2 +- .../types/capturedParametersOfInnerClasses.kt | 2 +- .../providers/impl/FirTypeResolverImpl.kt | 22 ++++++++++++------- .../jetbrains/kotlin/fir/types/TypeUtils.kt | 1 + .../fir/types/impl/FirErrorTypeRefImpl.kt | 2 -- .../org/jetbrains/kotlin/fir/FirRenderer.kt | 2 +- .../kotlin/fir/resolve/TreeResolveUtils.kt | 9 +------- .../generator/ImplementationConfigurator.kt | 3 +++ .../diagnostics/tests/EnumEntryAsType.fir.kt | 8 +++---- .../diagnostics/tests/Unresolved.fir.kt | 4 ++-- .../cast/bare/ErrorsInSubstitution.fir.kt | 2 +- .../tests/cast/bare/UnrelatedColon.fir.kt | 2 +- .../tests/classLiteral/arrays.fir.kt | 9 -------- .../diagnostics/tests/classLiteral/arrays.kt | 1 + .../generics/RawTypeInIsExpression.fir.kt | 2 +- .../tests/generics/RawTypeInIsPattern.fir.kt | 4 ++-- .../finalUpperBoundWithoutOverride.fir.kt | 2 +- .../tests/generics/genericsInType.fir.kt | 6 ++--- .../generics/innerClasses/bareTypes.fir.kt | 4 ++-- .../fromSuperClassesLocal.fir.kt | 4 ++-- .../fromSuperClassesLocalInsideInner.fir.kt | 4 ++-- .../innerClasses/importedInner.fir.kt | 2 +- .../outerArgumentsRequired.fir.kt | 6 ++--- .../innerClasses/qualifiedOuter.fir.kt | 2 +- .../qualifiedTypesResolution.fir.kt | 2 +- .../invalidArgumentsNumberInWhere.fir.kt | 20 ++++++++--------- .../controlStructuresErrors.fir.kt | 2 +- .../commonSuperTypeOfErrorTypes.fir.kt | 10 ++++----- .../tests/inner/deepInnerClass.fir.kt | 6 ++--- .../genericArgumentNumberMismatch.fir.kt | 4 ++-- .../extensionOnErrorType.fir.kt | 4 ++-- .../regressions/OrphanStarProjection.fir.kt | 2 +- .../tests/resolve/CycleInTypeArgs.fir.kt | 4 ++-- .../scopes/classHeader/classParents.fir.kt | 2 +- .../scopes/classHeader/objectParents.fir.kt | 2 +- .../diagnostics/tests/subtyping/kt304.fir.kt | 2 +- .../tests/thisAndSuper/Super.fir.kt | 2 +- ...pturingTypeParametersFromOuterClass.fir.kt | 8 +++---- .../javaStaticMembersViaTypeAlias.fir.kt | 10 ++++----- .../typealias/localTypeAliasRecursive.fir.kt | 4 ++-- .../tests/variance/InPosition.fir.kt | 8 +++---- .../tests/variance/InvariantPosition.fir.kt | 8 +++---- .../tests/variance/OutPosition.fir.kt | 8 +++---- .../InaccessibleInternalClass.fir.kt | 2 +- .../testsWithStdLib/regression/kt37727.fir.kt | 4 ++-- 50 files changed, 118 insertions(+), 125 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt index 40bcc35998d..aedd7069035 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt @@ -12,7 +12,7 @@ FILE: typeArgumentsNotAllowed.kt } public final fun foo(): R|kotlin/Unit| { R|rest/bar|<>() - R|rest/bar|<>() + R|rest/bar|>|>() } public final fun bar(): R|kotlin/Unit| { } @@ -41,9 +41,9 @@ FILE: typeArgumentsNotAllowed.kt public final fun gest(): R|kotlin/Unit| { } public final fun fest(): R|kotlin/Unit| { - lval b: + lval b: R|kotlin/collections/List| R|rest/gest|<>() R|rest/gest|() - lval c: - R|rest/gest|<>() + lval c: R|kotlin/collections/List>>| + R|rest/gest|>|>() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt index f0c353ed66f..9845330a969 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt @@ -23,7 +23,7 @@ FILE: upperBoundViolated.kt lval b2: R|B| = R|/B.B|() lval b3: R|B| = R|/B.B|() lval b4: R|B| = R|/B.B|<>() - lval b5: R|B| = R|/B.B|<>() + lval b5: R|B>| = R|/B.B||>() R|/fest|() R|/fest|() R|/fest|() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt index d1596c5afda..9e0ce9dcbfc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt @@ -15,7 +15,7 @@ fun test() { val b2 = B() val b3 = B<Any?>() val b4 = B<UnexistingType>() - val b5 = B<B>() + val b5 = B<B<UnexistingType>>() fest<Boolean>() fest() fest() diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt index 76a5371a0bd..3f336035ba4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt @@ -18,11 +18,11 @@ FILE: typeParameterVsNested.kt public abstract fun foo(arg: R|test/My.T|): R|kotlin/Unit| - public abstract val y: - public get(): + public abstract val y: + public get(): - public abstract val z: - public get(): + public abstract val z: + public get(): public final class Some : { public constructor(): R|test/My.Some| { diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt index 5181ec7b24e..ded00ddec29 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt @@ -9,9 +9,9 @@ abstract class My { abstract fun foo(arg: T) - abstract val y: My.T + abstract val y: My.T - abstract val z: test.My.T + abstract val z: test.My.T class Some : T() } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt index 459c37e8e6e..75eb3f942f9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt @@ -27,5 +27,5 @@ FILE: capturedParametersOfInnerClasses.kt } public final fun foo(c: R|A.B.C|): R|kotlin/Unit| { } - public final fun foo(c: ): R|kotlin/Unit| { + public final fun foo(c: ): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt index a6e88678f95..87bfbb31db0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt +++ b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt @@ -10,4 +10,4 @@ class A { fun foo(c: A.B.C) {} -fun foo(c: A.B.C) {} +fun foo(c: A.B.C) {} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt index 1a788330f45..232e6ec133c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt @@ -114,23 +114,29 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() { val isPossibleBareType = areBareTypesAllowed && typeArguments.isEmpty() if (typeArguments.size != symbol.fir.typeParameters.size && !isPossibleBareType) { @Suppress("NAME_SHADOWING") - val substitutor = substitutor ?: ConeSubstitutor.Empty - val n = symbol.fir.typeParameters.size - typeArguments.size - if (n < 0) { - typeArguments = (1..symbol.fir.typeParameters.size).map { - ConeClassErrorType(ConeWrongNumberOfTypeArgumentsError(typeArguments.size, symbol)) - }.toTypedArray() + if (symbol.fir.typeParameters.size < typeArguments.size) { + return ConeClassErrorType(ConeWrongNumberOfTypeArgumentsError(symbol.fir.typeParameters.size, symbol)) } else { - val argumentsFromOuterClassesAndParents = symbol.fir.typeParameters.takeLast(n).map { + val substitutor = substitutor ?: ConeSubstitutor.Empty + val argumentsFromOuterClassesAndParents = symbol.fir.typeParameters.drop(typeArguments.size).mapNotNull { val type = ConeTypeParameterTypeImpl(ConeTypeParameterLookupTag(it.symbol), isNullable = false) // we should report ConeSimpleDiagnostic(..., WrongNumberOfTypeArguments) // but genericArgumentNumberMismatch.kt test fails with // index out of bounds exception for start offset of // the source substitutor.substituteOrNull(type) - ?: ConeClassErrorType(ConeIntermediateDiagnostic("Type argument not defined")) + }.toTypedArray() typeArguments += argumentsFromOuterClassesAndParents + + if (typeArguments.size != symbol.fir.typeParameters.size) { + return ConeClassErrorType( + ConeWrongNumberOfTypeArgumentsError( + desiredCount = symbol.fir.typeParameters.size - argumentsFromOuterClassesAndParents.size, + type = symbol + ) + ) + } } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index cf0f97ff074..5faf26003be 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -236,6 +236,7 @@ fun FirTypeRef.withReplacedConeType( this@withReplacedConeType.source type = newType annotations += this@withReplacedConeType.annotations + delegatedTypeRef = this@withReplacedConeType.delegatedTypeRef } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index c376e7c25e3..0a1f8d570cd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -29,12 +29,10 @@ internal class FirErrorTypeRefImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } - delegatedTypeRef?.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirErrorTypeRefImpl { transformAnnotations(transformer, data) - delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data) return this } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 9223ab2c694..587da9cc36c 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -859,7 +859,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) { - visitTypeRef(errorTypeRef) + errorTypeRef.annotations.renderAnnotations() print("") } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt index bab010fe8b2..d6fdbd030c3 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt @@ -26,14 +26,7 @@ fun FirClassifierSymbol<*>.constructType( ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable, attributes) } is FirClassSymbol -> { - val errorTypeRef = typeArguments.find { - it is ConeClassErrorType - } - if (errorTypeRef is ConeClassErrorType) { - ConeClassErrorType(errorTypeRef.diagnostic) - } else { - ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable, attributes) - } + ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable, attributes) } is FirTypeAliasSymbol -> { ConeClassLikeTypeImpl( diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index ca0129fa92d..c51fe91e63c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -172,6 +172,9 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() default("type", "ConeClassErrorType(diagnostic)") default("annotations", "mutableListOf()") useTypes(coneClassErrorTypeType) + default("delegatedTypeRef") { + needAcceptAndTransform = false + } } diff --git a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt index 88ac6c4adcd..c51d4d4acf2 100644 --- a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt +++ b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt @@ -30,17 +30,17 @@ class MyColor(val x: Color.RED, y: Array? = null +fun create(): Array<Color.RED>? = null interface YourColor.RED> -class His : Your +class His : Your<Color.RED> fun Color.RED> otherCreate(): Array? = null typealias RedAlias = Color.RED -typealias ArrayOfEnumEntry = Array +typealias ArrayOfEnumEntry = Array<Color.RED> typealias ArrayOfEnumEntryAlias = Array @@ -52,4 +52,4 @@ fun foo() { bar<Color.RED>(Color.RED) } -fun Array.foo(entries: Array): Array = null!! \ No newline at end of file +fun Array<Color.RED>.foo(entries: Array<Color.RED>): Array<Color.RED> = null!! \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Unresolved.fir.kt b/compiler/testData/diagnostics/tests/Unresolved.fir.kt index d4133613353..ce9319e4fe7 100644 --- a/compiler/testData/diagnostics/tests/Unresolved.fir.kt +++ b/compiler/testData/diagnostics/tests/Unresolved.fir.kt @@ -3,8 +3,8 @@ package unresolved class Pair(val a: A, val b: B) fun testGenericArgumentsCount() { - val p1: Pair = Pair(2, 2) - val p2: Pair = Pair(2, 2) + val p1: Pair = Pair(2, 2) + val p2: Pair = Pair(2, 2) } fun testUnresolved() { diff --git a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt index 5b5c799c707..c36ceb82b82 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt @@ -3,7 +3,7 @@ interface B interface G: B -fun f(p: B): Any { +fun f(p: B<Foo>): Any { val v = p as G return checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt index b63ed2cd2b1..10a098124b5 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt @@ -4,4 +4,4 @@ interface Tr interface G -fun test(tr: Tr) = checkSubtype(tr) \ No newline at end of file +fun test(tr: Tr) = checkSubtype<G>(tr) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt b/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt deleted file mode 100644 index 8b87530bb2a..00000000000 --- a/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -// !LANGUAGE: +BareArrayClassLiteral - -val a01 = Array::class -val a02 = Array::class -val a03 = Array::class -val a04 = Array?>::class -val a05 = Array::class -val a06 = kotlin.Array::class -val a07 = kotlin.Array::class diff --git a/compiler/testData/diagnostics/tests/classLiteral/arrays.kt b/compiler/testData/diagnostics/tests/classLiteral/arrays.kt index 64cdf231d0d..1b19014d41f 100644 --- a/compiler/testData/diagnostics/tests/classLiteral/arrays.kt +++ b/compiler/testData/diagnostics/tests/classLiteral/arrays.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +BareArrayClassLiteral val a01 = Array::class diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt index dd9049258b6..08648c657fb 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt @@ -1,7 +1,7 @@ package p public fun foo(a: Any) { - a is Map + a is Map a is Map a is Map a is Map<*, *> diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt index bfca3e37219..167c86b8c8e 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt @@ -1,6 +1,6 @@ -public fun foo(a: Any, b: Map) { +public fun foo(a: Any, b: Map) { when (a) { - is Map -> {} + is Map -> {} is Map -> {} is Map -> {} is Map<*, *> -> {} diff --git a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt index 45cb5777982..d6c18a73b49 100644 --- a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt @@ -55,7 +55,7 @@ object MessageManager10 : Message5() { fun execute() {} } -class MessageManager11 : Message5>() { +class MessageManager11 : Message5<Message5>() { fun Message5> execute() {} } diff --git a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt index c7e6f18acd4..03a6774fddb 100644 --- a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt @@ -23,13 +23,13 @@ fun test() { Foo.Bar.Baz::class a.Bar>() - a.Bar.Baz>() + a<Foo.Bar.Baz>() a>() - a.Baz>() + a<Foo.Bar.Baz>() } -fun Foo> x() {} +fun String.Bar>> x() {} fun Foo.Bar.ext() {} fun ex1(a: Foo.Bar): Foo.Bar { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt index b88ad364875..c25f3d45412 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt @@ -15,6 +15,6 @@ class Outer { fun bare(x: Outer<*>.Inner<*, *>.Inner2Base, y: Outer<*>.Inner<*, *>.Inner3Base) { if (x is Outer.Inner.Inner2) return if (y is Outer.Inner.Inner3) return - if (y is Outer.Inner.Inner3) return - if (y is Outer.Inner.Inner3) return + if (y is Outer.Inner.Inner3) return + if (y is Outer.Inner.Inner3) return } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt index 56416b2ca57..603d640167d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt @@ -10,7 +10,7 @@ private fun foobar() = { fun a() = A() } - typealias LocalAlias = A + typealias LocalAlias = A<E, X, Y, W> } class Derived : LocalOuter() { @@ -27,7 +27,7 @@ private fun noParameters() = { fun a() = A() } - typealias LocalAlias2 = A + typealias LocalAlias2 = A<Any, X, Y, W> } class Derived2 : LocalOuter2() { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt index 75447981b2f..9f0071189a5 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt @@ -12,7 +12,7 @@ class Outer { fun a() = A() } - typealias LocalAlias = A + typealias LocalAlias = A<T, F, E, X, Y, W> } class Derived : LocalOuter() { @@ -29,7 +29,7 @@ class Outer { fun a() = A() } - typealias LocalAlias2 = A + typealias LocalAlias2 = A<T, F, Any, X, Y, W> } class Derived2 : LocalOuter2() { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt index 5246f574368..131b56d7afc 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt @@ -17,4 +17,4 @@ class Outer { class E -fun bar(x: Inner) {} +fun bar(x: Inner) {} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt index a26cddf1a78..259d8335b9d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt @@ -15,9 +15,9 @@ class A { val y: B.C? = null val z: B.D? = null - val c: C? = null - val d: D? = null + val c: C? = null + val d: D? = null - val innerMost: Innermost? = null + val innerMost: Innermost? = null } } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt index e365762a123..680ac81cc21 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt @@ -4,7 +4,7 @@ class Outer { inner class Inner - fun foo(x: Outer.Inner, y: Outer.Inner, z: Inner) { + fun foo(x: Outer.Inner, y: Outer.Inner, z: Inner) { var inner = Inner() x.checkType { _() } x.checkType { _.Inner>() } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt index 6e0cefa3c49..58fd1618b6d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt @@ -42,7 +42,7 @@ fun errorTypeWithArguments(): Q.W.R.M = n fun error1(): Outer.Inner.Inner3 = null!! fun error2(): Outer.Inner.Inner2 = null!! -fun error3(): Outer.Inner.Inner3 = null!! +fun error3(): Outer.Inner.Inner3 = null!! fun error4(): Outer.Nested.Inner4 = null!! fun error5(): Outer.Obj.Nested2.Inner5 = null!! diff --git a/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt b/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt index 4225780a004..ea3c40512f7 100644 --- a/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt @@ -1,19 +1,19 @@ class A -interface I0> -interface I1 where T : A -interface I2> where T : A +interface I0A> +interface I1 where T : A +interface I2A> where T : A -fun > foo0() {} -fun foo1() where E : A {} -fun > foo2() where E : A {} +fun A> foo0() {} +fun foo1() where E : A {} +fun A> foo2() where E : A {} -val > E.p1: Int +val A> E.p1: Int get() = 1 -val E.p2: Int where E : A +val E.p2: Int where E : A get() = 1 -val > E.p3: Int where E : A +val A> E.p3: Int where E : A get() = 1 // See KT-8200 interface X -public class EnumAttribute>(val klass: Class) where T : Enum +public class EnumAttributeX>(val klass: Class) where T : Enum diff --git a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt index 08b91385fad..06718ca85dc 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt @@ -19,7 +19,7 @@ fun test1() { } } -fun test2(l: List) { +fun test2(l: List<AA>) { l.map { it!! } diff --git a/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt index 38f020fede2..c1c3e279798 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt @@ -8,14 +8,14 @@ fun consume(x: Foo, y: Foo) {} fun materialize() = null as T fun test() { - consume( - materialize<Foo>>(), - materialize<Foo>>() + consume( + materializeErrorType>>>(), + materializeErrorType>>>() ) consume( - materialize<Foo>>(), - materialize<Foo>() + materializeErrorType>>>(), + materializeErrorType>>() ) } diff --git a/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt b/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt index 35335a385c6..bacd454df96 100644 --- a/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt +++ b/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt @@ -3,11 +3,11 @@ interface P class A { class B { fun test() { - class C() : P { - companion object : P { + class C() : PT> { + companion object : PT> { } - inner class D : P + inner class D : PT> } } } diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt index 830ca995ebf..d7184e68c6f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt @@ -6,7 +6,7 @@ package p public class A public class M1 { - public val a: A = A() + public val a: A = A() } // MODULE: m2 @@ -16,7 +16,7 @@ package p public class A -public fun foo(a: A) { +public fun foo(a: A) { } // MODULE: m3(m1, m2) diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt index 10292f79764..03781e5adfa 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt @@ -3,5 +3,5 @@ interface G { val bar: Int } -fun G.foo() {} -val G.bar: Int get() = 42 \ No newline at end of file +fun G.foo() {} +val G.bar: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt b/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt index a7e6c9f79df..2ec70721ce6 100644 --- a/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt @@ -1,3 +1,3 @@ class B {} -val b : B<*> = 1 +val b : B<*> = 1 diff --git a/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt b/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt index b6f853123b3..d8ef905f937 100644 --- a/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt @@ -1,3 +1,3 @@ -class Class1Class2>> +class Class1X>>> -class Class2Class1>> \ No newline at end of file +class Class2X>>> \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt index e7d485328fc..c3b8fec0203 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt @@ -2,7 +2,7 @@ interface I -class A(impl: Interface) : Nested(), Interface by impl, Inner, I { +class A(impl: Interface) : Nested(), Interface by impl, Inner, I<Nested, Interface, Inner> { class Nested diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt index c86b87fca24..d3a1ec33824 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt @@ -3,7 +3,7 @@ interface I val aImpl: A.Interface get() = null!! -object A : Nested(), Interface by aImpl, I { +object A : Nested(), Interface by aImpl, I<Nested, Interface> { class Nested diff --git a/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt b/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt index aab7fe69d26..95b34f3a56a 100644 --- a/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt +++ b/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt @@ -1,6 +1,6 @@ //KT-304: Resolve supertype reference to class anyway -open class Foo() : Bar() { +open class Foo() : Bar() { } open class Bar() { diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt index a391a2d06ac..6cc779c744b 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt @@ -50,7 +50,7 @@ class CG : G { fun test() { super.foo() // OK super>.foo() // Warning - super>.foo() // Error + super>.foo() // Error super>.foo() // Error } } diff --git a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt index 7f0daa5bcc7..bcbf49d0c3b 100644 --- a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt @@ -17,13 +17,13 @@ class Outer { fun foo() { class Local { - typealias LTF = List - typealias LTL = List + typealias LTF = List<TF> + typealias LTL = List<TL> } fun localfun() = object { - typealias LTF = List - typealias LTLF = List + typealias LTF = List<TF> + typealias LTLF = List<TLF> } } diff --git a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt index 06f1590bb1a..f35abf68cc9 100644 --- a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt @@ -38,9 +38,9 @@ val testNested2: KT.Nested = KT.IT.Nested = IT.Nested() val testInner1: JT.Inner = JT.Inner() val testInner2: KT.Inner = KT.Inner() -fun testNestedAsTypeArgument1(x: List) {} -fun testNestedAsTypeArgument2(x: List) {} -fun testNestedAsTypeArgument3(x: List) {} -fun testInnerAsTypeArgument1(x: List) {} -fun testInnerAsTypeArgument2(x: List) {} +fun testNestedAsTypeArgument1(x: List<JT.Nested>) {} +fun testNestedAsTypeArgument2(x: List<KT.Nested>) {} +fun testNestedAsTypeArgument3(x: List<IT.Nested>) {} +fun testInnerAsTypeArgument1(x: List<JT.Inner>) {} +fun testInnerAsTypeArgument2(x: List<KT.Inner>) {} diff --git a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt index 52a4006e8cf..4c0d7226f3d 100644 --- a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt @@ -2,6 +2,6 @@ fun outer() { typealias Test1 = Test1 - typealias Test2 = List - typealias Test3 = List> + typealias Test2 = List<Test2> + typealias Test3 = List<Test3<T>> } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt index 8a8b8171ec3..041174eefa2 100644 --- a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt @@ -41,10 +41,10 @@ interface Test { fun neOk11(i: Inv) fun neOk12(i: Inv) - fun neOk30(i: Pair) - fun neOk31(i: Pair) - fun neOk32(i: Inv) + fun neOk30(i: Pair) + fun neOk31(i: PairInv>) + fun neOk32(i: Inv) fun neOk33(i: Inv<>) - fun neOk34(i: Inv) + fun neOk34(i: Inv<C>) fun neOk35(i: Inv) } diff --git a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt index 4b0754eeb12..9fb72696400 100644 --- a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt @@ -38,10 +38,10 @@ interface Test { var neOk22: Inv var neOk23: Inv - var neOk30: Pair - var neOk31: Pair - var neOk32: Inv + var neOk30: Pair + var neOk31: PairInv> + var neOk32: Inv var neOk33: Inv<> - var neOk34: Inv + var neOk34: Inv<C> var neOk35: Inv } diff --git a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt index 7fa171d1429..a9d19182389 100644 --- a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt @@ -33,10 +33,10 @@ interface Test { fun neOk10(): Inv fun neOk11(): Inv - fun neOk30(): Pair - fun neOk31(): Pair - fun neOk32(): Inv + fun neOk30(): Pair + fun neOk31(): PairInv> + fun neOk32(): Inv fun neOk33(): Inv<> - fun neOk34(): Inv + fun neOk34(): Inv<C> fun neOk35(): Inv } diff --git a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt index 99a7d664c06..379189d3aef 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt @@ -10,6 +10,6 @@ package kotlin.sequences import p.* interface I { - val v1: FilteringSequence + val v1: FilteringSequence val v2: IndexingSequence } diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt index 72ea6639c4f..110550f7e97 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt @@ -1,5 +1,5 @@ -data class A(val x: Set = setOf()) { - fun with(x: Set? = null) { +data class A(val x: Set<CLassNotFound> = setOf()) { + fun with(x: Set<CLassNotFound>? = null) { A(x ?: this.x) } }