From 26e3a111d658ed49a6ccce645c7ba0bc0ef55661 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 30 Jul 2020 17:11:15 +0300 Subject: [PATCH] [FIR] Add diagnostics for object related problems --- .../diagnostics/localEntitytNotAllowed.kt | 31 +++++++ .../diagnostics/localEntitytNotAllowed.txt | 89 +++++++++++++++++++ .../diagnostics/manyCompanionObjects.kt | 19 ++++ .../diagnostics/manyCompanionObjects.txt | 41 +++++++++ .../diagnostics/typeParametersInObject.kt | 15 ++++ .../diagnostics/typeParametersInObject.txt | 36 ++++++++ .../resolve/expresssions/localObjects.kt | 2 +- .../fir/FirDiagnosticsTestGenerated.java | 15 ++++ ...DiagnosticsWithLightTreeTestGenerated.java | 15 ++++ .../declaration/DefaultDeclarationCheckers.kt | 5 +- .../FirLocalEntityNotAllowedChecker.kt | 37 ++++++++ .../FirManyCompanionObjectsChecker.kt | 38 ++++++++ .../FirTypeParametersInObjectChecker.kt | 30 +++++++ .../fir/analysis/diagnostics/FirErrors.kt | 5 ++ .../tests/FunctionReturnTypes.fir.kt | 4 +- .../tests/classObjects/ClassObjects.fir.kt | 6 +- .../multipleDissallowedDefaultObjects.fir.kt | 8 +- .../typeParametersInObject.fir.kt | 16 ++-- .../illegalModifiersOnClass.fir.kt | 6 +- .../funInterfaceDeclarationCheck.fir.kt | 4 +- .../property/unsupportedConstruction.fir.kt | 4 +- .../inline/unsupportedConstruction.fir.kt | 4 +- .../tests/inner/referenceToSelfInLocal.fir.kt | 30 ------- .../tests/inner/referenceToSelfInLocal.kt | 1 + .../diagnostics/tests/localInterfaces.fir.kt | 8 +- .../tests/objects/ObjectsLocal.fir.kt | 2 +- .../tests/objects/localObjects.fir.kt | 8 +- .../tests/resolve/localObject.fir.kt | 4 - .../diagnostics/tests/resolve/localObject.kt | 1 + .../unqualifiedSuperWithLocalClass.fir.kt | 4 +- ...mlNewWizardProjectImportTestGenerated.java | 4 +- .../YamlBuildFileGenerationTestGenerated.java | 4 +- 32 files changed, 419 insertions(+), 77 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.txt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirLocalEntityNotAllowedChecker.kt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirManyCompanionObjectsChecker.kt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTypeParametersInObjectChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/resolve/localObject.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt new file mode 100644 index 00000000000..064c23e4eae --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt @@ -0,0 +1,31 @@ +object A { + object B { + object C + } + + interface X + + val a = object : Any() { + object D { + object G + interface Z + } + + interface Y + } + + fun b() { + object E { + object F + interface M + } + + interface N + + val c = object : Any() { + val t = "test" + + interface U + } + } +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.txt new file mode 100644 index 00000000000..ff83835dd72 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.txt @@ -0,0 +1,89 @@ +FILE: localEntitytNotAllowed.kt + public final object A : R|kotlin/Any| { + private constructor(): R|A| { + super() + } + + public final object B : R|kotlin/Any| { + private constructor(): R|A.B| { + super() + } + + public final object C : R|kotlin/Any| { + private constructor(): R|A.B.C| { + super() + } + + } + + } + + public abstract interface X : R|kotlin/Any| { + } + + public final val a: R|| = object : R|kotlin/Any| { + private constructor(): R|| { + super() + } + + local final object D : R|kotlin/Any| { + private constructor(): R|A..D| { + super() + } + + local final object G : R|kotlin/Any| { + private constructor(): R|A..D.G| { + super() + } + + } + + local abstract interface Z : R|kotlin/Any| { + } + + } + + local abstract interface Y : R|kotlin/Any| { + } + + } + + public get(): R|| + + public final fun b(): R|kotlin/Unit| { + local final object E : R|kotlin/Any| { + private constructor(): R|A.E| { + super() + } + + local final object F : R|kotlin/Any| { + private constructor(): R|A.E.F| { + super() + } + + } + + local abstract interface M : R|kotlin/Any| { + } + + } + + local abstract interface N : R|kotlin/Any| { + } + + lval c: R|| = object : R|kotlin/Any| { + private constructor(): R|| { + super() + } + + public final val t: R|kotlin/String| = String(test) + public get(): R|kotlin/String| + + local abstract interface U : R|kotlin/Any| { + } + + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt new file mode 100644 index 00000000000..56f2aa83fdd --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt @@ -0,0 +1,19 @@ +class A { + companion object { + + } + + companion object { + + } +} + +class B { + companion object A { + + } + + companion object B { + + } +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.txt new file mode 100644 index 00000000000..9efe8a15e12 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.txt @@ -0,0 +1,41 @@ +FILE: manyCompanionObjects.kt + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|A.Companion| { + super() + } + + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|A.Companion| { + super() + } + + } + + } + public final class B : R|kotlin/Any| { + public constructor(): R|B| { + super() + } + + public final companion object A : R|kotlin/Any| { + private constructor(): R|B.A| { + super() + } + + } + + public final companion object B : R|kotlin/Any| { + private constructor(): R|B.B| { + super() + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt new file mode 100644 index 00000000000..b2600d87a4f --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt @@ -0,0 +1,15 @@ +object A { + object B +} + +class N { + companion object { + + } +} + +fun test() { + object M { + + } +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.txt new file mode 100644 index 00000000000..1e5534a3d5a --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.txt @@ -0,0 +1,36 @@ +FILE: typeParametersInObject.kt + public final object A : R|kotlin/Any| { + private constructor(): R|A| { + super() + } + + public final object B : R|kotlin/Any| { + private constructor(): R|A.B| { + super() + } + + } + + } + public final class N : R|kotlin/Any| { + public constructor(): R|N| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|N.Companion| { + super() + } + + } + + } + public final fun test(): R|kotlin/Unit| { + local final object M : R|kotlin/Any| { + private constructor(): R|M| { + super() + } + + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt index b67fbe95799..a90af6e1282 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt @@ -12,7 +12,7 @@ fun test() { } b.foo() - object B { + object B { fun foo() {} } B.foo() diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 135184802a2..00c9e09a8ef 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -916,6 +916,16 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/localAnnotationClass.kt"); } + @TestMetadata("localEntitytNotAllowed.kt") + public void testLocalEntitytNotAllowed() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt"); + } + + @TestMetadata("manyCompanionObjects.kt") + public void testManyCompanionObjects() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt"); + } + @TestMetadata("notASupertype.kt") public void testNotASupertype() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); @@ -961,6 +971,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/typeOfAnnotationMember.kt"); } + @TestMetadata("typeParametersInObject.kt") + public void testTypeParametersInObject() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt"); + } + @TestMetadata("upperBoundViolated.kt") public void testUpperBoundViolated() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 20b07a00b89..58b52e032cf 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -916,6 +916,16 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/localAnnotationClass.kt"); } + @TestMetadata("localEntitytNotAllowed.kt") + public void testLocalEntitytNotAllowed() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt"); + } + + @TestMetadata("manyCompanionObjects.kt") + public void testManyCompanionObjects() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt"); + } + @TestMetadata("notASupertype.kt") public void testNotASupertype() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); @@ -961,6 +971,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/typeOfAnnotationMember.kt"); } + @TestMetadata("typeParametersInObject.kt") + public void testTypeParametersInObject() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt"); + } + @TestMetadata("upperBoundViolated.kt") public void testUpperBoundViolated() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt"); diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt index e4da2cb1def..370839c1cfe 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DefaultDeclarationCheckers.kt @@ -11,7 +11,10 @@ import org.jetbrains.kotlin.fir.analysis.checkers.cfa.FirControlFlowChecker object CommonDeclarationCheckers : DeclarationCheckers() { override val declarationCheckers: List = listOf( FirAnnotationClassDeclarationChecker, - FirModifierChecker + FirModifierChecker, + FirManyCompanionObjectsChecker, + FirLocalEntityNotAllowedChecker, + FirTypeParametersInObjectChecker, ) override val memberDeclarationCheckers: List = listOf( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirLocalEntityNotAllowedChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirLocalEntityNotAllowedChecker.kt new file mode 100644 index 00000000000..80bdbed971c --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirLocalEntityNotAllowedChecker.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.* + +object FirLocalEntityNotAllowedChecker : FirBasicDeclarationChecker() { + override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration !is FirRegularClass || declaration.visibility != Visibilities.LOCAL) { + return + } + + when { + declaration.classKind == ClassKind.OBJECT && !declaration.isCompanion -> reporter.reportLocalObjectNotAllowed(declaration.source) + declaration.classKind == ClassKind.INTERFACE -> reporter.reportLocalInterfaceNotAllowed(declaration.source) + else -> { + } + } + } + + private fun DiagnosticReporter.reportLocalObjectNotAllowed(source: FirSourceElement?) { + source?.let { report(FirErrors.LOCAL_OBJECT_NOT_ALLOWED.on(it)) } + } + + private fun DiagnosticReporter.reportLocalInterfaceNotAllowed(source: FirSourceElement?) { + source?.let { report(FirErrors.LOCAL_INTERFACE_NOT_ALLOWED.on(it)) } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirManyCompanionObjectsChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirManyCompanionObjectsChecker.kt new file mode 100644 index 00000000000..6db99985826 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirManyCompanionObjectsChecker.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isCompanion + +object FirManyCompanionObjectsChecker : FirBasicDeclarationChecker() { + override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration !is FirRegularClass) { + return + } + + var hasCompanion = false + + for (it in declaration.declarations) { + if (it is FirRegularClass && it.isCompanion) { + if (hasCompanion) { + reporter.report(it.source) + } + hasCompanion = true + } + } + } + + private fun DiagnosticReporter.report(source: FirSourceElement?) { + source?.let { report(FirErrors.MANY_COMPANION_OBJECTS.on(it)) } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTypeParametersInObjectChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTypeParametersInObjectChecker.kt new file mode 100644 index 00000000000..e2913f3e6c8 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTypeParametersInObjectChecker.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirRegularClass + +object FirTypeParametersInObjectChecker : FirBasicDeclarationChecker() { + override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration !is FirRegularClass || declaration.classKind != ClassKind.OBJECT) { + return + } + + if (declaration.typeParameters.isNotEmpty()) { + reporter.report(declaration.source) + } + } + + private fun DiagnosticReporter.report(source: FirSourceElement?) { + source?.let { report(FirErrors.TYPE_PARAMETERS_IN_OBJECT.on(it)) } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 12d504cbcac..7020196fda4 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -81,6 +81,11 @@ object FirErrors { val PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT by error0() val UPPER_BOUND_VIOLATED by error0() + val MANY_COMPANION_OBJECTS by error0() + val LOCAL_OBJECT_NOT_ALLOWED by error0() + val LOCAL_INTERFACE_NOT_ALLOWED by error0() + val TYPE_PARAMETERS_IN_OBJECT by error0() + // Control flow diagnostics val UNINITIALIZED_VARIABLE by error1() diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt index 8d72e507236..628041e7526 100644 --- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.fir.kt @@ -194,7 +194,7 @@ fun testFunctionLiterals() { val endsWithObjectDeclaration : () -> Int = { var x = 1 x = 333 - object A {} + object A {} } val expectedUnitReturnType1: () -> Unit = { @@ -203,7 +203,7 @@ fun testFunctionLiterals() { val expectedUnitReturnType2: () -> Unit = { fun meow() : Unit {} - object A {} + object A {} } } diff --git a/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt b/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt index 4cb3dd4fc51..6a3c83fa9cb 100644 --- a/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt @@ -5,7 +5,7 @@ class A { companion object { val x = 1 } - companion object { + companion object { val x = 1 } } @@ -14,10 +14,10 @@ class AA { companion object { val x = 1 } - companion object A { + companion object A { val x = 1 } - companion object AA { + companion object AA { val x = 1 } } diff --git a/compiler/testData/diagnostics/tests/classObjects/multipleDissallowedDefaultObjects.fir.kt b/compiler/testData/diagnostics/tests/classObjects/multipleDissallowedDefaultObjects.fir.kt index de7b2f48423..690eadf9944 100644 --- a/compiler/testData/diagnostics/tests/classObjects/multipleDissallowedDefaultObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/multipleDissallowedDefaultObjects.fir.kt @@ -2,16 +2,16 @@ class A { inner class I { companion object A - companion object B + companion object B - companion object C + companion object C } } object O { companion object A - companion object B + companion object B - companion object C + companion object C } diff --git a/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.fir.kt b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.fir.kt index f9320366c44..d47c0663b00 100644 --- a/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/typeParametersInObject.fir.kt @@ -1,21 +1,21 @@ -object A -object B -object C> +object A +object B +object C> class D { - companion object + companion object } class E { - companion object + companion object } class F { - companion object C> + companion object C> } class G { - companion object F + companion object F } -object H() +object H() diff --git a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt index 342314424da..91ae4434e08 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt @@ -4,9 +4,9 @@ override class A { override companion object {} - open companion object {} - abstract companion object {} - final companion object {} + open companion object {} + abstract companion object {} + final companion object {} } override object B1 {} diff --git a/compiler/testData/diagnostics/tests/funInterface/funInterfaceDeclarationCheck.fir.kt b/compiler/testData/diagnostics/tests/funInterface/funInterfaceDeclarationCheck.fir.kt index b93f7b75793..ae051437cf0 100644 --- a/compiler/testData/diagnostics/tests/funInterface/funInterfaceDeclarationCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/funInterface/funInterfaceDeclarationCheck.fir.kt @@ -87,9 +87,9 @@ class WithNestedFun { } fun local() { - fun interface LocalFun { + fun interface LocalFun { fun invoke(element: T) - } + } } fun interface WithDefaultValue { diff --git a/compiler/testData/diagnostics/tests/inline/property/unsupportedConstruction.fir.kt b/compiler/testData/diagnostics/tests/inline/property/unsupportedConstruction.fir.kt index a97b55cd40a..1c3cc5dd2e9 100644 --- a/compiler/testData/diagnostics/tests/inline/property/unsupportedConstruction.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/property/unsupportedConstruction.fir.kt @@ -9,8 +9,8 @@ inline val z: Int } } - object B{ - object BInner {} + object B{ + object BInner {} } fun local() { diff --git a/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.fir.kt b/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.fir.kt index 55269200a9a..a660ebca0bd 100644 --- a/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/unsupportedConstruction.fir.kt @@ -9,8 +9,8 @@ inline fun unsupported() { } } - object B{ - object BInner {} + object B{ + object BInner {} } fun local() { diff --git a/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.fir.kt b/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.fir.kt deleted file mode 100644 index cc02038def3..00000000000 --- a/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -// KT-4351 Cannot resolve reference to self in init of class local to function - -fun f() { - class MyClass() { - init { - val x: MyClass = MyClass() - } - - fun member() { - val x: MyClass = MyClass() - } - } - - object MyObject { - init { - val obj: MyObject = MyObject - } - } - - val x: MyClass = MyClass() -} - -val closure = { - class MyClass { - init { - val x: MyClass = MyClass() - } - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.kt b/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.kt index a359b467051..df9d1a4e9b1 100644 --- a/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.kt +++ b/compiler/testData/diagnostics/tests/inner/referenceToSelfInLocal.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE // KT-4351 Cannot resolve reference to self in init of class local to function diff --git a/compiler/testData/diagnostics/tests/localInterfaces.fir.kt b/compiler/testData/diagnostics/tests/localInterfaces.fir.kt index 5e5af2f9926..85615bc8335 100644 --- a/compiler/testData/diagnostics/tests/localInterfaces.fir.kt +++ b/compiler/testData/diagnostics/tests/localInterfaces.fir.kt @@ -1,14 +1,14 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE fun foo() { - interface a {} + interface a {} val b = object { - interface c {} + interface c {} } class A { - interface d {} + interface d {} } val f = { - interface e {} + interface e {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/ObjectsLocal.fir.kt b/compiler/testData/diagnostics/tests/objects/ObjectsLocal.fir.kt index 38cd5054c67..3072349f9f2 100644 --- a/compiler/testData/diagnostics/tests/objects/ObjectsLocal.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/ObjectsLocal.fir.kt @@ -16,7 +16,7 @@ fun test() { } b.foo() - object B { + object B { fun foo() {} } B.foo() diff --git a/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt b/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt index 0ec89e28f78..daaac36cf4b 100644 --- a/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/localObjects.fir.kt @@ -1,15 +1,15 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE fun foo() { - object a {} + object a {} val b = object { - object c {} + object c {} } b.c class A { - object d {} + object d {} } val f = { - object e {} + object e {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/localObject.fir.kt b/compiler/testData/diagnostics/tests/resolve/localObject.fir.kt deleted file mode 100644 index 098f25c28e3..00000000000 --- a/compiler/testData/diagnostics/tests/resolve/localObject.fir.kt +++ /dev/null @@ -1,4 +0,0 @@ -fun foo(): Any { - object Bar - return Bar -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/localObject.kt b/compiler/testData/diagnostics/tests/resolve/localObject.kt index c649b686303..34dd9be674d 100644 --- a/compiler/testData/diagnostics/tests/resolve/localObject.kt +++ b/compiler/testData/diagnostics/tests/resolve/localObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun foo(): Any { object Bar return Bar diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithLocalClass.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithLocalClass.fir.kt index 51bb88b6904..7045253537b 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithLocalClass.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/unqualifiedSuperWithLocalClass.fir.kt @@ -8,10 +8,10 @@ fun withLocalClasses(param: Int): Interface { get() = 100 } - interface LocalInterface : Interface { + interface LocalInterface : Interface { override fun foo(x: Int): Int = x + param - } + } return object : LocalBase(), LocalInterface { override fun foo(x: Int): Int = diff --git a/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/YamlNewWizardProjectImportTestGenerated.java b/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/YamlNewWizardProjectImportTestGenerated.java index 01e781b439f..8bd5a319fee 100644 --- a/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/YamlNewWizardProjectImportTestGenerated.java +++ b/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/YamlNewWizardProjectImportTestGenerated.java @@ -227,12 +227,12 @@ public class YamlNewWizardProjectImportTestGenerated extends AbstractYamlNewWiza } @TestMetadata("singlePlatformJsBrowser") - public void testSingleplatformJsBrowser() throws Exception { + public void testSinglePlatformJsBrowser() throws Exception { runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/singlePlatformJsBrowser/"); } @TestMetadata("singlePlatformJsNode") - public void testSingleplatformJsNode() throws Exception { + public void testSinglePlatformJsNode() throws Exception { runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/singlePlatformJsNode/"); } } diff --git a/libraries/tools/new-project-wizard/new-project-wizard-cli/tests/org/jetbrains/kotlin/tools/projectWizard/cli/YamlBuildFileGenerationTestGenerated.java b/libraries/tools/new-project-wizard/new-project-wizard-cli/tests/org/jetbrains/kotlin/tools/projectWizard/cli/YamlBuildFileGenerationTestGenerated.java index 21f59961901..7a41ec491f7 100644 --- a/libraries/tools/new-project-wizard/new-project-wizard-cli/tests/org/jetbrains/kotlin/tools/projectWizard/cli/YamlBuildFileGenerationTestGenerated.java +++ b/libraries/tools/new-project-wizard/new-project-wizard-cli/tests/org/jetbrains/kotlin/tools/projectWizard/cli/YamlBuildFileGenerationTestGenerated.java @@ -79,12 +79,12 @@ public class YamlBuildFileGenerationTestGenerated extends AbstractYamlBuildFileG } @TestMetadata("singlePlatformJsBrowser") - public void testSingleplatformJsBrowser() throws Exception { + public void testSinglePlatformJsBrowser() throws Exception { runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/singlePlatformJsBrowser/"); } @TestMetadata("singlePlatformJsNode") - public void testSingleplatformJsNode() throws Exception { + public void testSinglePlatformJsNode() throws Exception { runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/singlePlatformJsNode/"); } }