diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 7fc823f2e09..09b0ee50625 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -27644,6 +27644,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/resolve/localObject.kt"); } + @Test + @TestMetadata("nestedClassUnresolvedReference.kt") + public void testNestedClassUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt"); + } + @Test @TestMetadata("newLineLambda.kt") public void testNewLineLambda() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index eac967e3fd3..d3b8dbafa39 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -27644,6 +27644,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/resolve/localObject.kt"); } + @Test + @TestMetadata("nestedClassUnresolvedReference.kt") + public void testNestedClassUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt"); + } + @Test @TestMetadata("newLineLambda.kt") public void testNewLineLambda() throws Exception { diff --git a/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.fir.txt b/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.fir.txt index 2bade46d399..6d0165dda97 100644 --- a/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.fir.txt @@ -1,3 +1,3 @@ FILE: fakeRecursiveTypealias.kt - public final typealias My = + public final typealias My = public final typealias Your = /Your> diff --git a/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.kt b/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.kt index c255a90e643..ff0c203a27f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.kt +++ b/compiler/fir/analysis-tests/testData/resolve/fakeRecursiveTypealias.kt @@ -1,5 +1,5 @@ import incorrect.directory.Your -typealias My = incorrect.directory.My +typealias My = incorrect.directory.My typealias Your = Your diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/exposedSupertype.kt b/compiler/fir/analysis-tests/testData/resolve/visibility/exposedSupertype.kt index 08c5787cc23..5177fb499e3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/visibility/exposedSupertype.kt +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/exposedSupertype.kt @@ -58,6 +58,6 @@ class Test6 : E, D.PublicButProtected { +class Test7 : D.PublicButProtected { } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 23470946f63..91e0e895734 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -27644,6 +27644,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/resolve/localObject.kt"); } + @Test + @TestMetadata("nestedClassUnresolvedReference.kt") + public void testNestedClassUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt"); + } + @Test @TestMetadata("newLineLambda.kt") public void testNewLineLambda() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index c895998940d..a86b03a2d6a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -27656,6 +27656,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/resolve/localObject.kt"); } + @Test + @TestMetadata("nestedClassUnresolvedReference.kt") + public void testNestedClassUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt"); + } + @Test @TestMetadata("newLineLambda.kt") public void testNewLineLambda() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index 768948da30b..f02eff96a2d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.KtRealSourceElementKind import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.diagnostics.* @@ -56,7 +57,18 @@ private fun ConeDiagnostic.toKtDiagnostic( is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.classId.asString(), null) is ConeUnresolvedNameError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, name.asString(), operatorToken) - is ConeUnresolvedTypeQualifierError -> FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier, null) + is ConeUnresolvedTypeQualifierError -> { + if (source?.kind == KtRealSourceElementKind) { + // this.qualifiers will contain all resolved qualifiers from the left up to (including) the first unresolved qualifier. + // We want to report UNRESOLVED_REFERENCE exactly on the first unresolved qualifier with its name as argument. + // Examples: Unresolved, Unresolved.Foo, + // Resolved.Unresolved, Resolved.Unresolved.Foo + val lastQualifier = this.qualifiers.last() + FirErrors.UNRESOLVED_REFERENCE.createOn(lastQualifier.source, lastQualifier.name.asString(), null) + } else { + FirErrors.UNRESOLVED_REFERENCE.createOn(source, this.qualifier, null) + } + } is ConeFunctionCallExpectedError -> FirErrors.FUNCTION_CALL_EXPECTED.createOn(source, this.name.asString(), this.hasValueParameters) is ConeFunctionExpectedError -> FirErrors.FUNCTION_EXPECTED.createOn(source, this.expression, this.type) is ConeNoConstructorError -> FirErrors.NO_CONSTRUCTOR.createOn(callOrAssignmentSource ?: source) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt index 5638c409771..635b263506b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.recordTypeLookup import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.FirTypeResolutionResult import org.jetbrains.kotlin.fir.resolve.SupertypeSupplier +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedTypeQualifierError import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnsupportedDefaultValueInFunctionType import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType import org.jetbrains.kotlin.fir.resolve.typeResolver @@ -145,26 +146,7 @@ class FirSpecificTypeResolverTransformer( ): FirResolvedTypeRef { return when { resolvedType is ConeErrorType -> { - buildErrorTypeRef { - val typeRefSourceKind = typeRef.source?.kind - val diagnosticSource = (resolvedType.diagnostic as? ConeUnexpectedTypeArgumentsError)?.source - - source = if (diagnosticSource != null) { - if (typeRefSourceKind is KtFakeSourceElementKind) { - diagnosticSource.fakeElement(typeRefSourceKind) - } else { - diagnosticSource - } - } else { - typeRef.source - } - - delegatedTypeRef = typeRef - type = resolvedType - partiallyResolvedTypeRef = tryCalculatingPartiallyResolvedTypeRef(typeRef, scopeClassDeclaration) - - this.diagnostic = resolvedType.diagnostic - } + buildErrorType(typeRef, resolvedType, scopeClassDeclaration) } diagnostic != null -> { buildErrorTypeRef { @@ -186,6 +168,45 @@ class FirSpecificTypeResolverTransformer( } } + private fun buildErrorType( + typeRef: FirTypeRef, + resolvedType: ConeErrorType, + scopeClassDeclaration: ScopeClassDeclaration, + ): FirErrorTypeRef { + return buildErrorTypeRef { + var diagnostic = resolvedType.diagnostic + val typeRefSourceKind = typeRef.source?.kind + val diagnosticSource = (diagnostic as? ConeUnexpectedTypeArgumentsError)?.source + + source = if (diagnosticSource != null) { + if (typeRefSourceKind is KtFakeSourceElementKind) { + diagnosticSource.fakeElement(typeRefSourceKind) + } else { + diagnosticSource + } + } else { + typeRef.source + } + + delegatedTypeRef = typeRef + type = resolvedType + val partiallyResolvedTypeRef = tryCalculatingPartiallyResolvedTypeRef(typeRef, scopeClassDeclaration) + this.partiallyResolvedTypeRef = partiallyResolvedTypeRef + + if (diagnostic is ConeUnresolvedTypeQualifierError) { + val totalQualifierCount = diagnostic.qualifiers.size + val resolvedQualifierCount = (partiallyResolvedTypeRef?.delegatedTypeRef as? FirUserTypeRef)?.qualifier?.size ?: 0 + val unresolvedQualifierCount = totalQualifierCount - resolvedQualifierCount + + if (unresolvedQualifierCount > 1) { + diagnostic = ConeUnresolvedTypeQualifierError(diagnostic.qualifiers.dropLast(unresolvedQualifierCount - 1), false) + } + } + + this.diagnostic = diagnostic + } + } + /** * Tries to calculate a partially resolved type reference for a type reference which was resolved to an error type. * It will attempt to resolve the type with a decreasing number of qualifiers until it succeeds, allowing @@ -197,7 +218,7 @@ class FirSpecificTypeResolverTransformer( * @param data The scope class declaration containing relevant information for resolving the reference. * @return A partially resolved type reference if it was resolved, or `null` otherwise. */ - private fun tryCalculatingPartiallyResolvedTypeRef(typeRef: FirTypeRef, data: ScopeClassDeclaration): FirTypeRef? { + private fun tryCalculatingPartiallyResolvedTypeRef(typeRef: FirTypeRef, data: ScopeClassDeclaration): FirResolvedTypeRef? { if (typeRef !is FirUserTypeRef) return null val qualifiers = typeRef.qualifier if (qualifiers.size <= 1) { diff --git a/compiler/testData/diagnostics/tests/LocalClassAndShortSubpackageNames.fir.kt b/compiler/testData/diagnostics/tests/LocalClassAndShortSubpackageNames.fir.kt index 4fd57a471e7..68bc2bc9d48 100644 --- a/compiler/testData/diagnostics/tests/LocalClassAndShortSubpackageNames.fir.kt +++ b/compiler/testData/diagnostics/tests/LocalClassAndShortSubpackageNames.fir.kt @@ -9,7 +9,7 @@ package foo fun f() { class Local1 { - fun g() : bar.X? = null + fun g() : bar.X? = null } class Local2 { fun g() : foo.bar.X? = null diff --git a/compiler/testData/diagnostics/tests/PackageQualified.fir.kt b/compiler/testData/diagnostics/tests/PackageQualified.fir.kt index 07788fdd66b..6f3e96382be 100644 --- a/compiler/testData/diagnostics/tests/PackageQualified.fir.kt +++ b/compiler/testData/diagnostics/tests/PackageQualified.fir.kt @@ -6,8 +6,8 @@ package foobar.a import java.* val a : java.util.List? = null - val a2 : util.List? = null - val a3 : LinkedList? = null + val a2 : util.List? = null + val a3 : LinkedList? = null // FILE: b.kt package foobar @@ -21,7 +21,7 @@ package foobar.a import java.util.* val b : List? = a - val b1 : util.List? = a + val b1 : util.List? = a // FILE: d.kt package foobar diff --git a/compiler/testData/diagnostics/tests/ResolveToJava.fir.kt b/compiler/testData/diagnostics/tests/ResolveToJava.fir.kt index ee617d0112c..90190beda55 100644 --- a/compiler/testData/diagnostics/tests/ResolveToJava.fir.kt +++ b/compiler/testData/diagnostics/tests/ResolveToJava.fir.kt @@ -15,10 +15,10 @@ import java.lang.Comparable as Com val l : MutableList = ArrayList() fun test(l : java.util.List) { - val x : java.List + val x : java.List val y : java.util.List val b : java.lang.Object - val z : java.utils.List + val z : java.utils.List val f : java.io.File? = null diff --git a/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt b/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt index 060d89e47f1..3cf30b4ea9b 100644 --- a/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/unresolvedReferenceRange.fir.kt @@ -1,5 +1,5 @@ @Ann class A @Ann class B @Ann(1) class C -@kotlin.Ann(1) class D -@kotlin.annotation.Ann(1) class E \ No newline at end of file +@kotlin.Ann(1) class D +@kotlin.annotation.Ann(1) class E diff --git a/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.fir.kt b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.fir.kt index 110aabab7a8..cbf8ba8df1f 100644 --- a/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.fir.kt @@ -1,10 +1,10 @@ class DTO { val q: Int = 0 - operator fun get(prop: KProperty1<*, Int>): Int = 0 + operator fun get(prop: KProperty1<*, Int>): Int = 0 } -fun foo(intDTO: DTO?, p: KProperty1<*, Int>) { +fun foo(intDTO: DTO?, p: KProperty1<*, Int>) { if (intDTO != null) { intDTO[DTO::q] intDTO.q diff --git a/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.fir.kt b/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.fir.kt deleted file mode 100644 index ed78494d92b..00000000000 --- a/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.fir.kt +++ /dev/null @@ -1 +0,0 @@ -fun testing(a: Any) = a is UnresolvedType diff --git a/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.kt b/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.kt index f88613e0aeb..a10180893a4 100644 --- a/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.kt +++ b/compiler/testData/diagnostics/tests/cast/IsErasedToErrorType.kt @@ -1 +1,2 @@ +// FIR_IDENTICAL fun testing(a: Any) = a is UnresolvedType diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt index 2a0bfcee7ae..cf43d817d00 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt @@ -22,7 +22,7 @@ object DefaultHttpClientWithFun : HttpClient by fClient() { private fun fClient() = HttpClientImpl() -private fun lazy(init: () -> T): kotlin.Lazy { +private fun lazy(init: () -> T): kotlin.Lazy { init() null!! } diff --git a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt deleted file mode 100644 index 56570792dbd..00000000000 --- a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt +++ /dev/null @@ -1,82 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// SKIP_TXT -// Issues: KT-25105 - -class Message1 -class Task -object Message2 -enum class Message3 -data class Message4(val x: Int) -interface Manager {} - -object MessageManager1 : Manager { - fun Message1> execute1(task: Task) {} - fun Int> execute2(task: T) {} - fun Message2> execute3() {} -} - -object MessageManager2 : Manager { - fun execute4() {} -} - -object MessageManager3 : Manager { - fun Message4> execute5() {} -} - -class MessageManager4 : Manager { - fun Message1> execute1(task: Task) {} - fun Int> execute2(task: T) {} - fun Message2> execute3() {} -} - -class MessageManager5 : Manager { - fun execute4() {} -} - -class MessageManager6 : Manager { - fun Message4> execute5() {} -} - -interface MessageManager7 : Manager { - fun Message4> execute5() {} -} - -interface MessageManager8 : Manager { - fun Message1> execute1(task: Task) {} - fun Int> execute2(task: T) {} - fun Message2> execute3() {} -} - -interface MessageManager9 : Manager { - fun execute4() {} -} - -object MessageManager10 : Message5() { - fun Int> execute() {} -} - -class MessageManager11 : Message5<Message5>() { - fun Message5> execute() {} -} - -data class MessageManager12(val x: Int) : Message5() { - fun Message2> execute() {} -} - -sealed class MessageManager13 : Message5() { - fun execute() {} -} - -class MessageManager14 : Manager { - val Message2> T.x get() = 10 - var Message2> T.y - get() = 10 - set(value) {} -} - -object MessageManager15 : Manager { - val Int> T.x get() = 10 - var Int> T.y - get() = 10 - set(value) {} -} diff --git a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.kt b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.kt index a35a01fc012..879ae2d4a79 100644 --- a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.kt +++ b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // SKIP_TXT // Issues: KT-25105 diff --git a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt index 337a7b096f5..6f5f7a68577 100644 --- a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt @@ -29,7 +29,7 @@ fun test() { a.Baz>() } -fun String.Bar>> x() {} +fun Bar>> x() {} fun Foo.Bar.ext() {} fun ex1(a: Foo.Bar): Foo.Bar { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.fir.kt deleted file mode 100644 index 90bd9a47b54..00000000000 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.fir.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -open class Outer { - inner class Inner - -} - -class Derived : Outer() { - // Inner here means Outer.Inner - fun foo(x: Inner) {} -} - -class A { - companion object : Outer() - - // Does not work, could be Outer.Inner - // TODO: Should work? - fun foo(x: Inner) { - // Inner() call use companion as implicit receiver - val y: Outer.Inner = Inner() - } -} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt index 79ae47ad23b..3dc398b1ca1 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE open class Outer { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.fir.kt index baa47a6d32c..b5988b2d93c 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.fir.kt @@ -15,7 +15,7 @@ class A { // Does not work, could be Outer.Inner // TODO: Should work? - fun foo(x: Inner) { + fun foo(x: Inner) { // Inner() call use companion as implicit receiver val y: Outer.Inner = Inner() } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClasses.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClasses.fir.kt index 148afb2ec25..958109f0e95 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClasses.fir.kt @@ -7,14 +7,14 @@ open class Outer { class Derived : Outer() { fun foo(): Inner = null!! - fun baz(): Alias = null!! + fun baz(): Alias = null!! } class A : Outer() { class B : Outer() { fun bar(): Inner = null!! - fun x(): Alias = null!! + fun x(): Alias = null!! } } 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 befadb24e61..f25e01526a3 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt @@ -14,7 +14,7 @@ private fun foobar() = { class Derived : LocalOuter() { fun foo(): LocalInner = null!! - fun bar(): LocalAlias = null!! + fun bar(): LocalAlias = null!! } Derived() @@ -31,7 +31,7 @@ private fun noParameters() = { class Derived2 : LocalOuter2() { fun foo(): LocalInner2 = null!! - fun bar(): LocalAlias2 = null!! + fun bar(): LocalAlias2 = null!! } Derived2() 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 f31e8c4fb6a..d5ceb9abc81 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt @@ -16,7 +16,7 @@ class Outer { class Derived : LocalOuter() { fun foo(): LocalInner = null!! - fun bar(): LocalAlias = null!! + fun bar(): LocalAlias = null!! } Derived() @@ -33,7 +33,7 @@ class Outer { class Derived2 : LocalOuter2() { fun foo(): LocalInner2 = null!! - fun bar(): LocalAlias2 = null!! + fun bar(): LocalAlias2 = null!! } Derived2() } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesTransitive.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesTransitive.fir.kt index 770e4dbd4b3..aa61d6e6633 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesTransitive.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesTransitive.fir.kt @@ -10,7 +10,7 @@ open class BaseDerived2 : BaseDerived1() class Derived : BaseDerived2() { fun foo(): Inner = null!! - fun baz(): Alias = null!! + fun baz(): Alias = null!! } fun foo() { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt index bf58d75921c..7ffa632526e 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt @@ -38,7 +38,7 @@ fun ok4(): Outer.Obj.Nested2.Inner5 = null!! fun ok5(): test.Outer.Obj.Nested2.Inner5 = null!! // All arguments are resolved -fun errorTypeWithArguments(): Q.W.R.M = null!! +fun errorTypeWithArguments(): Q.W.R.M = null!! fun error1(): Outer.Inner.Inner3 = null!! fun error2(): Outer.Inner.Inner2 = null!! diff --git a/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.fir.kt b/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.fir.kt deleted file mode 100644 index 8bc935e1b32..00000000000 --- a/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -interface I0Unresolved0> -interface I1 where T : Unresolved1 -interface I2<T : Unresolved2> where T : Unresolved3 - -fun Unresolved4> foo0() {} -fun foo1() where E : Unresolved5 {} -fun <E : Unresolved6> foo2() where E : Unresolved7 {} - -val Unresolved7> E.p1: Int - get() = 1 -val E.p2: Int where E : Unresolved8 - get() = 1 -val <E : Unresolved9> E.p3: Int where E : Unresolved10 - get() = 1 diff --git a/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.kt b/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.kt index 644d648bda2..559c239a812 100644 --- a/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.kt +++ b/compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface I0Unresolved0> interface I1 where T : Unresolved1 interface I2<T : Unresolved2> where T : Unresolved3 diff --git a/compiler/testData/diagnostics/tests/imports/ExplicitPackageImportsAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/imports/ExplicitPackageImportsAmbiguity.fir.kt index 62c31a650bc..4269bd208d6 100644 --- a/compiler/testData/diagnostics/tests/imports/ExplicitPackageImportsAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/imports/ExplicitPackageImportsAmbiguity.fir.kt @@ -14,4 +14,4 @@ package c import a.x import b.x -class Y : x.X \ No newline at end of file +class Y : x.X diff --git a/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.fir.kt deleted file mode 100644 index 6bd14a5d485..00000000000 --- a/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -abstract class MyClass { - abstract fun foo(): (P1) -> Unknown - - private fun callTryConvertConstant() { - println(foo()) - } -} diff --git a/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.kt b/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.kt index 7f547b4812f..af2fc9cc8c6 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/unresolvedTypeWithTypeArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL abstract class MyClass { abstract fun foo(): (P1) -> Unknown diff --git a/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.fir.kt b/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.fir.kt deleted file mode 100644 index bfa7870bd4f..00000000000 --- a/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// !LANGUAGE: +PartiallySpecifiedTypeArguments -// !DIAGNOSTICS: -UNCHECKED_CAST -// WITH_STDLIB - -fun foo(x: (K) -> T): Pair = (1 as K) to (1f as T) - -@Repeatable -@Target(AnnotationTarget.TYPE) -annotation class Anno - -@Repeatable -@Target(AnnotationTarget.TYPE) -annotation class Anno2 - -@Repeatable -@Target(AnnotationTarget.TYPE) -annotation class Anno3(val x: String) - -fun box(): String { - val x = foo<@Anno Int, @Anno _> { it.toFloat() } - val y: Pair = foo<@[Anno Anno2] _, @Anno _> { it.toFloat() } - val z1: Pair = foo<@Anno @Anno2 /**/ _, @[/**/ Anno /**/ ] _> { it.toFloat() } - val z2: Pair = foo<@Anno3("") /**/ _, @[/**/ Anno /**/ Anno3("") /**/] _,> { it.toFloat() } - - val z31: Pair<@Anno3("") _, Float> = 1 to 1f - val z33: Pair<@Anno3("") (_), Float> = 1 to 1f - val z35: Pair<(@Anno3("") (_)), Float> = 1 to 1f - - return "OK" -} diff --git a/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.kt b/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.kt index 6173fbc432f..c99c1959920 100644 --- a/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.kt +++ b/compiler/testData/diagnostics/tests/inference/annotatedUnderscoredTypeArgument.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +PartiallySpecifiedTypeArguments // !DIAGNOSTICS: -UNCHECKED_CAST // WITH_STDLIB diff --git a/compiler/testData/diagnostics/tests/inference/kt11963.fir.kt b/compiler/testData/diagnostics/tests/inference/kt11963.fir.kt index 682e90dfb85..175f18f4620 100644 --- a/compiler/testData/diagnostics/tests/inference/kt11963.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/kt11963.fir.kt @@ -1 +1 @@ -val <T : KClass.something> abc +val <T : KClass.something> abc diff --git a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt index 1552b559c59..666e2be1836 100644 --- a/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/underscoredTypeInForbiddenPositions.fir.kt @@ -6,7 +6,7 @@ fun foo(x: (K) -> T): Pair = (1 as K) to (1f as T) class Foo -class Bar0_<_>> +class Bar0_<_>> class Bar1_>> class Bar2_> class Bar3 where K : _ @@ -16,7 +16,7 @@ typealias A1<_> = = Foo<_> typealias A3 = (_) -> T typealias A4 = (T) -> () -> _ -typealias A5 = (T) -> (((_))) -> T +typealias A5 = (T) -> (((_))) -> T fun foo1(x: _) {} fun foo2(x: Foo<_>) {} @@ -33,14 +33,14 @@ fun <`_`> bar(): Foo<_> = TODO() fun test() { val x1 = foo_) -> Unit> { { it } } val x2 = foo _> { { it } } - val x3 = foo(_)) -> _> { { it } } + val x3 = foo_)) -> _> { { it } } val x4 = foo<Int, _ -> Float> { { it } } val x5 = foo_) -> Float>> { { it } } val x6 = foo_) -> _>> { { it } } val x7 = foo _>> { { it } } val z32: Pair<_, Float> = 1 to 1f - val z34: Pair<((_)), Float> = 1 to 1f + val z34: Pair<((_)), Float> = 1 to 1f val x8: (Float) -> Int = { x: _ -> 10 } val x9: (Foo) -> Int = { x: Foo<_> -> 10 } @@ -58,7 +58,7 @@ fun test() { val x13: Foo<@_() Int>? = null val x14: Foo<@Anno(_) Int>? = null - val x15: _<_>? = null + val x15: _<_>? = null } @Target(AnnotationTarget.TYPE) diff --git a/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.fir.kt b/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.fir.kt deleted file mode 100644 index a046c76c5a8..00000000000 --- a/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.fir.kt +++ /dev/null @@ -1,64 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE - -// FILE: A.java - -public class A { - static class NC {} - class IC {} - static interface NI {} -} - -// FILE: I.java - -public interface I { - class NC {} - interface NI {} -} - -// FILE: B.java - -public class B extends A { - -} - -// FILE: C.java - -public class C implements I { - -} - -// FILE: D.java - -public class D extends A implements I { - -} - -// FILE: K.kt - -class K : D() - -// FILE: test.kt - -fun test() { - val ac: A.NC = A.NC() - val aic: A.IC = A().IC() - val ai: A.NI? = null - - val ic: I.NC = I.NC() - val ii: I.NI? = null - - val bc: B.NC = B.NC() - val bic: B.IC = B().IC() - val bi: B.NI? = null - - val cc: C.NC = C.NC() - val ci: C.NI? = null - - val dc: D.NC = D.NC() - val dic: D.IC = D().IC() - val di: D.NI? = null - - val kc: K.NC = K.NC() - val kic: K.IC = K().IC() - val ki: K.NI? = null -} diff --git a/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.kt b/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.kt index d12ab66ddfd..ecd44719df4 100644 --- a/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.kt +++ b/compiler/testData/diagnostics/tests/inner/accessingToJavaNestedClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE // FILE: A.java diff --git a/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.fir.kt b/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.fir.kt deleted file mode 100644 index c7e8c2d5997..00000000000 --- a/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.fir.kt +++ /dev/null @@ -1,44 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE - -open class A { - class NC {} - inner class IC {} - interface NI {} -} - -interface I { - class NC {} - interface NI {} -} - -class B : A() { - -} - -class C : I { - -} - -class D : A(), I { - -} - -fun test() { - val ac: A.NC = A.NC() - val aic: A.IC = A().IC() - val ai: A.NI? = null - - val ic: I.NC = I.NC() - val ii: I.NI? = null - - val bc: B.NC = B.NC() - val bic: B.IC = B().IC() - val bi: B.NI? = null - - val cc: C.NC = C.NC() - val ci: C.NI? = null - - val dc: D.NC = D.NC() - val dic: D.IC = D().IC() - val di: D.NI? = null -} diff --git a/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.kt b/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.kt index a961b7e7567..8cd38de0192 100644 --- a/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.kt +++ b/compiler/testData/diagnostics/tests/inner/accessingToKotlinNestedClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE open class A { diff --git a/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.fir.kt b/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.fir.kt deleted file mode 100644 index bfc55e0e171..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -class Foo { - companion object { - val bar = 1 - - fun test(a: Foo.`object`) { - - } - - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.kt b/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.kt index ac418c77d4c..e64e5d20518 100644 --- a/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.kt +++ b/compiler/testData/diagnostics/tests/j+k/accessClassObjectFromJava.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class Foo { companion object { val bar = 1 diff --git a/compiler/testData/diagnostics/tests/qualifiedExpression/TypeWithError.fir.kt b/compiler/testData/diagnostics/tests/qualifiedExpression/TypeWithError.fir.kt index 6cf18760663..831b357ff51 100644 --- a/compiler/testData/diagnostics/tests/qualifiedExpression/TypeWithError.fir.kt +++ b/compiler/testData/diagnostics/tests/qualifiedExpression/TypeWithError.fir.kt @@ -14,18 +14,18 @@ fun test1(a: A.B.): A.B. { val aa: A.B. = null!! } -fun test2(a: A.e.C): A.e.C { - val aa: A.e.C = null!! +fun test2(a: A.e.C): A.e.C { + val aa: A.e.C = null!! } -fun test3(a: a.A.C): a.A.C { - val aa: a.A.C = null!! +fun test3(a: a.A.C): a.A.C { + val aa: a.A.C = null!! } -fun test4(a: A.B.ee): A.B.ee { - val aa: A.B.ee = null!! +fun test4(a: A.B.ee): A.B.ee { + val aa: A.B.ee = null!! } -fun test5(a: A.ee): A.ee { - val aa: A.ee = null!! +fun test5(a: A.ee): A.ee { + val aa: A.ee = null!! } diff --git a/compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt b/compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt new file mode 100644 index 00000000000..3bf1a591949 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt @@ -0,0 +1,24 @@ +// FIR_IDENTICAL +// DIAGNOSTICS: -DEBUG_INFO_MISSING_UNRESOLVED + +fun ch( + x1: Foo.Bar, + x2: Foo.Bar.Baz, + x3: Outer.Foo, + x4: Outer.Foo.Bar, + x5: Outer.Nested.Foo, + x6: Outer.Nested.Foo.Bar, + x7: Outer.Nested.Nested2.Foo, + x8: Outer.Nested.Nested2.Foo.Bar, + x9: Outer.Inner.Foo, + x10: Outer.O.Foo, +) {} + +class Outer { + class Nested { + class Nested2 + } + + inner class Inner + object O +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.fir.kt deleted file mode 100644 index 934a279a0bb..00000000000 --- a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// !LANGUAGE: +ProhibitSmartcastsOnLocalDelegatedProperty - -class AlternatingDelegate { - var counter: Int = 0 - operator fun getValue(thisRef: Any?, property: KProperty<*>): Any? = - if (counter++ % 2 == 0) 42 else "" -} - -fun failsWithClassCastException() { - val sometimesNotInt: Any? by AlternatingDelegate() - - if (sometimesNotInt is Int) { - sometimesNotInt.inc() - } -} diff --git a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.kt b/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.kt index c6f33e34985..b49b0391bbc 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyAfter.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ProhibitSmartcastsOnLocalDelegatedProperty class AlternatingDelegate { diff --git a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyBefore.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyBefore.fir.kt index 13b63862b6b..3c8ef35ae65 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyBefore.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/localDelegatedPropertyBefore.fir.kt @@ -2,7 +2,7 @@ class AlternatingDelegate { var counter: Int = 0 - operator fun getValue(thisRef: Any?, property: KProperty<*>): Any? = + operator fun getValue(thisRef: Any?, property: KProperty<*>): Any? = if (counter++ % 2 == 0) 42 else "" } diff --git a/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.fir.kt b/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.fir.kt deleted file mode 100644 index 1c6d7e80042..00000000000 --- a/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS -UNUSED_PARAMETER -fun f1(l: List1): T {throw Exception()} // ERROR type here -fun f1(l: List2): T {throw Exception()} // ERROR type here -fun f1(c: Collection): T{throw Exception()} - -fun test(l: List) { - f1(l) -} diff --git a/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.kt b/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.kt index 86392f91495..0f3d5af658f 100644 --- a/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.kt +++ b/compiler/testData/diagnostics/tests/substitutions/upperBoundsSubstitutionForOverloadResolutionWithErrorTypes.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -CONFLICTING_JVM_DECLARATIONS -UNUSED_PARAMETER fun f1(l: List1): T {throw Exception()} // ERROR type here fun f1(l: List2): T {throw Exception()} // ERROR type here diff --git a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.fir.kt deleted file mode 100644 index 9feb9dff699..00000000000 --- a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.fir.kt +++ /dev/null @@ -1,2 +0,0 @@ -// ISSUE: KT-56212 -fun F.X.f(): Boolean = false diff --git a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.kt b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.kt index c7bcfb688f7..f1bdee3bb74 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReceiver.kt @@ -1,2 +1,3 @@ +// FIR_IDENTICAL // ISSUE: KT-56212 fun F.X.f(): Boolean = false diff --git a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.fir.kt deleted file mode 100644 index 1cd0086e1f5..00000000000 --- a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.fir.kt +++ /dev/null @@ -1,2 +0,0 @@ -// ISSUE: KT-56212 -fun foo(): F.X = TODO() diff --git a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.kt b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.kt index a553b2bc1a6..2ed9a78a8ed 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/typeParameterChainInReturnType.kt @@ -1,2 +1,3 @@ +// FIR_IDENTICAL // ISSUE: KT-56212 fun foo(): F.X = TODO() diff --git a/compiler/testData/diagnostics/tests/typealias/inhreritedTypeAliasQualifiedByDerivedClass.fir.kt b/compiler/testData/diagnostics/tests/typealias/inhreritedTypeAliasQualifiedByDerivedClass.fir.kt index 5d4051e26f2..36931d48356 100644 --- a/compiler/testData/diagnostics/tests/typealias/inhreritedTypeAliasQualifiedByDerivedClass.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/inhreritedTypeAliasQualifiedByDerivedClass.fir.kt @@ -6,8 +6,8 @@ open class Base { class Derived : Base() -fun test(x: Derived.Nested) = x +fun test(x: Derived.Nested) = x fun Base.testWithImplicitReceiver(x: Nested) { val y: Nested = x -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt deleted file mode 100644 index f35abf68cc9..00000000000 --- a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt +++ /dev/null @@ -1,46 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: JTest.java -public class JTest { - public static String foo() { return ""; } - public static class Nested {} -} - -// FILE: JDerived.java -public class JDerived extends JTest { -} - -// FILE: test.kt -class KTest { - class Nested - inner class Inner -} - -interface ITest { - class Nested -} - -typealias JT = JTest -typealias JD = JDerived -typealias KT = KTest -typealias IT = ITest - -// Referencing Java class static members via type alias should be ok -val testFoo: String = JT.foo() -val seeAlsoFoo: String = JTest.foo() -// Referencing base Java class static members via type alias for derived Java class should be ok -val testDerivedFoo: String = JD.foo() -val seeAlsoDerivedFoo: String = JDerived.foo() - -// Referencing nested classes via type alias should be prohibited -// (in type position and in expression position) -val testNested1: JT.Nested = JT.Nested() -val testNested2: KT.Nested = KT.Nested() -val testNested3: IT.Nested = IT.Nested() -val testInner1: JT.Inner = JT.Inner() -val testInner2: KT.Inner = KT.Inner() -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/javaStaticMembersViaTypeAlias.kt b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.kt index 3f7dde38819..3c22c3a2b79 100644 --- a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.kt +++ b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // FILE: JTest.java public class JTest { diff --git a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt index f5478555e63..59811464e68 100644 --- a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt @@ -3,5 +3,5 @@ fun outer() { typealias Test1 = Test1 typealias Test2 = List<Test2> - typealias Test3 = List<Test3> + typealias Test3 = List<Test3> } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt index 7af7d47da05..6cf209d84c6 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.fir.kt @@ -38,13 +38,13 @@ enum class EnumSample { fun foo( a0: test.ClassSample.Nested, - a1: test.ClassAlias.Nested, + a1: test.ClassAlias.Nested, b0: test.ObjectSample.Nested, - b1: test.ObjectAlias.Nested, + b1: test.ObjectAlias.Nested, c0: test.EnumSample.Nested, - c1: test.EnumAlias.Nested + c1: test.EnumAlias.Nested ) { test.ClassSample::Nested test.ClassAlias::Nested diff --git a/compiler/testData/diagnostics/tests/variance/ea1337846.fir.kt b/compiler/testData/diagnostics/tests/variance/ea1337846.fir.kt deleted file mode 100644 index 7885d1cce3b..00000000000 --- a/compiler/testData/diagnostics/tests/variance/ea1337846.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// https://ea.jetbrains.com/browser/ea_reports/1337846 - -//interface ComputablePoint -// -//interface ComputableSegment -// -//interface ComputableLineSegment : ComputableSegment - -//interface Path - -typealias EachSegmentComparator = (currentSegment: SegmentType, otherSegment: SegmentType, relationship: Int) -> Boolean - -interface ComputablePath - : Path -where - NumberType: Number, - PointType: ComputablePoint, - SegmentType: ComputableLineSegment -{ - fun anyTwoSegments(comparator: EachSegmentComparator<ComputableSegment>): Boolean -} diff --git a/compiler/testData/diagnostics/tests/variance/ea1337846.kt b/compiler/testData/diagnostics/tests/variance/ea1337846.kt index 35739c8272d..8b3a07f9c16 100644 --- a/compiler/testData/diagnostics/tests/variance/ea1337846.kt +++ b/compiler/testData/diagnostics/tests/variance/ea1337846.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // https://ea.jetbrains.com/browser/ea_reports/1337846 //interface ComputablePoint diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt index 06b067e5d90..3658b85f27d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.fir.kt @@ -2,7 +2,7 @@ interface Inv class Impl : Inv -class Scope(private val implClass: j.Class) { +class Scope(private val implClass: j.Class) { fun foo(c: Collection) { val hm = c.asSequence() .filter(implClass::isInstance) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.fir.kt deleted file mode 100644 index 5b5f961f592..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -// FILE: 1.kt -fun test(c: Continuation) {} - -// FILE: 2.kt -import kotlin.coroutines.* - -fun test2(c: Continuation) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.kt index ac7e761cc9a..ea32539f472 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/noDefaultCoroutineImports.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: 1.kt fun test(c: Continuation) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.fir.kt deleted file mode 100644 index 71e52932b83..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !LANGUAGE: +Coroutines -// !DIAGNOSTICS: -USELESS_IS_CHECK -// SKIP_TXT - -fun test() { - suspend {} is SuspendFunction0<*> - suspend {} is kotlin.coroutines.SuspendFunction0<*> -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.kt index 95709df9529..c706551a837 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionN.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +Coroutines // !DIAGNOSTICS: -USELESS_IS_CHECK // SKIP_TXT diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionType/suspendFunctionN.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionType/suspendFunctionN.fir.kt index d0379d3dd47..9259e28a103 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionType/suspendFunctionN.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctionType/suspendFunctionN.fir.kt @@ -1,4 +1,4 @@ // SKIP_JAVAC -typealias Test1 = SuspendFunction0 -typealias Test2 = kotlin.SuspendFunction0 +typealias Test1 = SuspendFunction0 +typealias Test2 = kotlin.SuspendFunction0 typealias Test3 = kotlin.coroutines.SuspendFunction0 diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index d768759d683..d8105c6e006 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -29300,6 +29300,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/resolve/localObject.kt"); } + @Test + @TestMetadata("nestedClassUnresolvedReference.kt") + public void testNestedClassUnresolvedReference() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/nestedClassUnresolvedReference.kt"); + } + @Test @TestMetadata("newLineLambda.kt") public void testNewLineLambda() throws Exception { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index 2cbe08703e4..6bae42d39cf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -188,7 +188,7 @@ fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndire else "-1" // TESTCASE NUMBER: 13 -fun case_13(x: otherpackage.Case13?) = +fun case_13(x: otherpackage.Case13?) = if ((x == null !is Boolean) !== true) { throw Exception() } else { @@ -198,7 +198,7 @@ fun case_13(x: otherpackage.Case13?) = // TESTCASE NUMBER: 14 class Case14 { - val x: otherpackage.Case14? + val x: otherpackage.Case14? init { x = otherpackage.Case14() }