From 4669e019d14af987fc77b0aedf283eb8f7f71316 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 5 Aug 2020 09:35:10 +0300 Subject: [PATCH] [FIR] Add diagnostic CONFLICTING_OVERLOADS & REDECLARATION --- .../RedundantSetterParameterTypeChecker.kt | 8 +- .../RedundantVisibilityModifierChecker.kt | 8 +- .../VariableAssignmentChecker.kt | 6 +- .../diagnostics/conflictingOverloads.kt | 68 ++++++++ .../diagnostics/conflictingOverloads.txt | 124 +++++++++++++++ .../diagnostics/manyCompanionObjects.kt | 4 +- .../resolve/expresssions/objectVsProperty.kt | 4 +- .../mixingImplicitAndExplicitReceivers.kt | 4 +- .../smartcasts/safeCalls/assignSafeCall.kt | 8 +- .../testData/resolve/whenElse.kt | 8 +- .../callableReferences/beyoundCalls.kt | 4 +- .../lowPriorityInResolution.kt | 6 +- .../testData/resolveWithStdlib/problems.kt | 4 +- .../fir/FirDiagnosticsTestGenerated.java | 5 + ...DiagnosticsWithLightTreeTestGenerated.java | 5 + .../kotlin/fir/analysis/CheckersComponent.kt | 10 +- .../checkers/FirDeclarationInspector.kt | 146 ++++++++++++++++++ .../declaration/DeclarationCheckers.kt | 4 + .../declaration/DefaultDeclarationCheckers.kt | 9 ++ .../declaration/FirConflictsChecker.kt | 67 ++++++++ .../declaration/FirDeclarationChecker.kt | 7 +- .../declaration/FirModifierChecker.kt | 7 +- .../DeclarationCheckersDiagnosticComponent.kt | 6 +- .../diagnostics/FirDefaultErrorMessages.kt | 4 + .../fir/analysis/diagnostics/FirErrors.kt | 2 + .../jetbrains/kotlin/fir/types/ArrayUtils.kt | 2 +- .../unsignedTypes/varargsOfUnsignedTypes.kt | 1 - .../tests/classObjects/ClassObjects.fir.kt | 4 +- .../classObjectRedeclaration.fir.kt | 12 +- .../conflictingCopyOverloads.fir.kt | 4 +- .../dataClasses/repeatedProperties.fir.kt | 8 +- .../MultiDeclarationErrors.fir.kt | 4 +- .../ForLoopComponentFunctionAmbiguity.fir.kt | 4 +- .../illegalModifiersOnClass.fir.kt | 8 +- .../specialNames/classObject.fir.kt | 4 +- .../classObjectCopiedFieldObject.fir.kt | 4 +- .../captureFromNullableTypeVariable.fir.kt | 2 +- .../binaryExpressions/mathOperations.fir.kt | 8 +- ...eclarationWithWeakIncompatibilities.fir.kt | 4 +- .../conflictingHeaderDeclarations.fir.kt | 8 - .../conflictingHeaderDeclarations.kt | 1 + .../conflictingImplDeclarations.fir.kt | 8 +- .../headerDeclarationWithBody.fir.kt | 4 +- ...OverloadsFunsDifferentReturnInClass.fir.kt | 6 +- ...erloadsFunsDifferentReturnInPackage.fir.kt | 8 +- ...gOverloadsIdenticalExtFunsInPackage.fir.kt | 4 +- ...ictingOverloadsIdenticalFunsInClass.fir.kt | 8 +- ...ictingOverloadsIdenticalValsInClass.fir.kt | 4 +- ...ngOverloadsValsDifferentTypeInClass.fir.kt | 4 +- .../TypeParameterMultipleBounds.fir.kt | 8 +- .../tests/override/DuplicateMethod.fir.kt | 4 +- .../ConflictingExtensionProperties.fir.kt | 4 +- .../PropertyAndInnerClass.fir.kt | 8 +- .../RedeclarationInDefaultObject.fir.kt | 4 +- .../RedeclarationMainInFile.fir.kt | 4 +- .../redeclarations/Redeclarations.fir.kt | 6 +- .../RedeclarationsInObjects.fir.kt | 8 +- .../RedeclaringPrivateToFile.fir.kt | 12 +- .../TopLevelPropertyVsClassifier.fir.kt | 20 +-- .../redeclarations/TypeAliasVsClass.fir.kt | 16 +- .../redeclarations/TypeAliasVsProperty.fir.kt | 8 +- .../tests/redeclarations/kt2438.fir.kt | 12 +- .../tests/redeclarations/kt470.fir.kt | 56 +++---- .../tests/regressions/Jet11.fir.kt | 4 +- .../resolveWithRedeclarationError.fir.kt | 54 +++---- ...redeclarationsOfConstructorsIgnored.fir.kt | 6 +- .../suspendConflictsWithNoSuspend.fir.kt | 12 +- .../noInferAndLowPriority.fir.kt | 8 +- .../onlyInputTypesAndLowPriority.fir.kt | 8 +- .../abstract-classes/p-2/neg/1.4.fir.kt | 4 +- .../p-14/neg/1.1.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/14.fir.kt | 6 +- 72 files changed, 681 insertions(+), 247 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.txt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.fir.kt diff --git a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantSetterParameterTypeChecker.kt b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantSetterParameterTypeChecker.kt index 566e938613b..c7a61f7cd1e 100644 --- a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantSetterParameterTypeChecker.kt +++ b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantSetterParameterTypeChecker.kt @@ -2,15 +2,15 @@ @Target(AnnotationTarget.CLASS) annotation class Ann -var x: Int +var x: Int get() = 1 - set(@Ann private x) { } + set(@Ann private x) { } -var x: String = "" +var x: String = "" set(param: String) { field = "$param " - } + } class My { var y: Int = 1 diff --git a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantVisibilityModifierChecker.kt b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantVisibilityModifierChecker.kt index 473c692097d..60bb9ed977f 100644 --- a/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantVisibilityModifierChecker.kt +++ b/compiler/fir/analysis-tests/testData/extendedCheckers/RedundantVisibilityModifierChecker.kt @@ -11,11 +11,11 @@ internal inline fun internal() { f() } -class C { +class C { internal val z = object { fun foo() = 13 } -} +} class Foo2< T1, @@ -27,12 +27,12 @@ class Foo2< internal inner class B } -public class C { +public class C { public val foo: Int = 0 public fun bar() {} -} +} open class D { protected open fun willRemainProtected() { diff --git a/compiler/fir/analysis-tests/testData/extendedCheckers/VariableAssignmentChecker.kt b/compiler/fir/analysis-tests/testData/extendedCheckers/VariableAssignmentChecker.kt index f924c4a4db0..d89bde6a57a 100644 --- a/compiler/fir/analysis-tests/testData/extendedCheckers/VariableAssignmentChecker.kt +++ b/compiler/fir/analysis-tests/testData/extendedCheckers/VariableAssignmentChecker.kt @@ -17,7 +17,7 @@ class LocalFreezableVar(private var value: T) { } -class C +class C operator fun C.plus(a: Any): C = this operator fun C.plusAssign(a: Any) {} @@ -172,14 +172,14 @@ fun notAssignedWhenNotUsed(p: Int) { var global = 1 -class C { +class C { var field = 2 fun foo() { print(field) print(global) } -} +} fun withDelegate() { var s: String by Delegates.notNull() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt new file mode 100644 index 00000000000..18944e0d232 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt @@ -0,0 +1,68 @@ +fun test(x: Int) {} + +fun test(y: Int) {} + +fun test() {} + +fun test(z: Int, c: Char) {} + +open class A { + open fun rest(s: String) {} + + open val u = 20 +} + +class A { + +} + +class B : A { + override fun rest(s: String) {} + + fun rest(s: String) {} + + fun rest(l: Long) {} + + override val u = 310 +} + +interface B + +enum class B + +val u = 10 +val u = 20 + +typealias TA = A +typealias TA = B + +typealias BA = A + +fun kek(t: T) where T : (String) -> Any?, T : Char {} +fun kek(t: T) where T : () -> Boolean, T : String {} +fun kek(t: T) {} + +fun lol(a: Array) {} +fun lol(a: Array) {} + +fun mem(t: T) where T : () -> Boolean, T : String {} +fun mem(t: T) where T : String, T : () -> Boolean {} + +class M { + companion object {} + val Companion = object : Any {} +} + +fun B.foo() {} + +class L { + fun B.foo() {} +} + +fun mest() + +class mest + +fun() {} + +private fun() {} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.txt new file mode 100644 index 00000000000..3e429144200 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.txt @@ -0,0 +1,124 @@ +FILE: conflictingOverloads.kt + public final fun test(x: R|kotlin/Int|): R|kotlin/Unit| { + } + public final fun test(y: R|kotlin/Int|): R|kotlin/Unit| { + } + public final fun test(): R|kotlin/Unit| { + } + public final fun test(z: R|kotlin/Int|, c: R|kotlin/Char|): R|kotlin/Unit| { + } + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public open fun rest(s: R|kotlin/String|): R|kotlin/Unit| { + } + + public open val u: R|kotlin/Int| = Int(20) + public get(): R|kotlin/Int| + + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public final class B : R|A| { + public constructor(): R|B| { + super() + } + + public final override fun rest(s: R|kotlin/String|): R|kotlin/Unit| { + } + + public final fun rest(s: R|kotlin/String|): R|kotlin/Unit| { + } + + public final fun rest(l: R|kotlin/Long|): R|kotlin/Unit| { + } + + public final override val u: R|kotlin/Int| = Int(310) + public get(): R|kotlin/Int| + + } + public abstract interface B : R|kotlin/Any| { + } + public final enum class B : R|kotlin/Enum| { + private constructor(): R|B| { + super|>() + } + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|B| { + } + + } + public final val u: R|kotlin/Int| = Int(10) + public get(): R|kotlin/Int| + public final val u: R|kotlin/Int| = Int(20) + public get(): R|kotlin/Int| + public final typealias TA = R|A| + public final typealias TA = R|B| + public final typealias BA = R|A| + public final fun kotlin/Any?|, R|kotlin/Char|> kek(t: R|T|): R|kotlin/Unit| { + } + public final fun kotlin/Boolean|, R|kotlin/String|> kek(t: R|T|): R|kotlin/Unit| { + } + public final fun kek(t: R|T|): R|kotlin/Unit| { + } + public final fun lol(a: R|kotlin/Array|): R|kotlin/Unit| { + } + public final fun lol(a: R|kotlin/Array|): R|kotlin/Unit| { + } + public final fun kotlin/Boolean|, R|kotlin/String|> mem(t: R|T|): R|kotlin/Unit| { + } + public final fun kotlin/Boolean|> mem(t: R|T|): R|kotlin/Unit| { + } + public final class M : R|kotlin/Any| { + public constructor(): R|M| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|M.Companion| { + super() + } + + } + + public final val Companion: R|| = object : R|kotlin/Any| { + private constructor(): R|| { + super() + } + + } + + public get(): R|| + + } + public final fun R|B|.foo(): R|kotlin/Unit| { + } + public final class L : R|kotlin/Any| { + public constructor(): R|L| { + super() + } + + public final fun R|B|.foo(): R|kotlin/Unit| { + } + + } + public final fun mest(): R|kotlin/Unit| + public final class mest : R|kotlin/Any| { + public constructor(): R|mest| { + super() + } + + } + public final fun (): R|kotlin/Unit| { + } + private final fun (): R|kotlin/Unit| { + } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt index 56f2aa83fdd..165d3911fc2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt @@ -1,9 +1,9 @@ class A { - companion object { + companion object { } - companion object { + companion object { } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/objectVsProperty.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/objectVsProperty.kt index 95efedee634..2f741aa3133 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/objectVsProperty.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/objectVsProperty.kt @@ -1,6 +1,6 @@ -object A +object A -val A = 10 +val A = 10 fun foo() = A diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt index 1fb3e08bfe4..025700d52e9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt @@ -1,4 +1,4 @@ -fun takeString(s: String) {} +fun takeString(s: String) {} class Wrapper(val s: String?) { fun withThis() { @@ -11,4 +11,4 @@ class Wrapper(val s: String?) { } } -fun takeString(s: String) {} \ No newline at end of file +fun takeString(s: String) {} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt index 2498a8ed2f2..f0cefdea95a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt @@ -23,11 +23,11 @@ fun test_2(a: A?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? A ?: return a.foo() // Should be OK x.foo() // Should be OK -} +} // ----------------- Unstable ----------------- @@ -53,8 +53,8 @@ fun test_2(a: B?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? B ?: return a.foo() // Should be OK x.foo() // Should be OK -} \ No newline at end of file +} \ No newline at end of file diff --git a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt index 4fcd6982b97..82295985eea 100644 --- a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt +++ b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt @@ -13,7 +13,7 @@ class B() class C(val b : B) fun get(f: Boolean) = if (f) {A.A1} else {""} -fun case2() { +fun case2() { val flag: Any = get(false) //string val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN @@ -25,9 +25,9 @@ fun case2() { A.A1 -> B() A.A2 -> B() } -} +} -fun case2() { +fun case2() { val flag: Any = get(true) //A val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN @@ -39,7 +39,7 @@ fun case2() { A.A1 -> B() A.A2 -> B() } -} +} fun case3() { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt index 0e8e0dc27cb..51dd56f6405 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt @@ -1,5 +1,5 @@ -fun bar(x: String): Int = 1 -fun bar(x: String): Double = 1 +fun bar(x: String): Int = 1 +fun bar(x: String): Double = 1 fun baz(x: String): Int = 1 fun foobaz(x: T): R = TODO() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt index 5aefcce5892..dfbc77b8778 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt @@ -1,8 +1,8 @@ -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.LowPriorityInOverloadResolution -fun foo(): Int = 1 +fun foo(): Int = 1 -fun foo(): String = "" +fun foo(): String = "" fun test() { val s = foo() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.kt index d4a23a10f98..49296c70021 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.kt @@ -13,7 +13,7 @@ fun test() { val Any.bar get() = "456" val String.bar get() = "987" -val t = "".bar +val t = "".bar val p = Pair(0, "") @@ -21,4 +21,4 @@ class Base(val x: T) class Derived : Base(10) val xx = Derived().x + 1 -val t = throw AssertionError("") \ No newline at end of file +val t = throw AssertionError("") \ No newline at end of file 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 e906bb20da3..4706dfd933c 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,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/anonymousObjectByDelegate.kt"); } + @TestMetadata("conflictingOverloads.kt") + public void testConflictingOverloads() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt"); + } + @TestMetadata("cyclicConstructorDelegationCall.kt") public void testCyclicConstructorDelegationCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.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 b16cd11d7ad..fede8cccaec 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,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/anonymousObjectByDelegate.kt"); } + @TestMetadata("conflictingOverloads.kt") + public void testConflictingOverloads() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt"); + } + @TestMetadata("cyclicConstructorDelegationCall.kt") public void testCyclicConstructorDelegationCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt"); diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/CheckersComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/CheckersComponent.kt index 313fe351087..d2abed004b6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/CheckersComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/CheckersComponent.kt @@ -53,25 +53,31 @@ fun FirSession.registerCheckersComponent() { } private class ComposedDeclarationCheckers : DeclarationCheckers() { + override val fileCheckers: List + get() = _fileCheckers override val declarationCheckers: List get() = _declarationCheckers - override val memberDeclarationCheckers: List get() = _memberDeclarationCheckers - + override val regularClassCheckers: List + get() = _regularClassCheckers override val constructorCheckers: List get() = _constructorCheckers override val controlFlowAnalyserCheckers: List get() = _controlFlowAnalyserCheckers + private val _fileCheckers: MutableList = mutableListOf() private val _declarationCheckers: MutableList = mutableListOf() private val _memberDeclarationCheckers: MutableList = mutableListOf() + private val _regularClassCheckers: MutableList = mutableListOf() private val _constructorCheckers: MutableList = mutableListOf() private val _controlFlowAnalyserCheckers: MutableList = mutableListOf() fun register(checkers: DeclarationCheckers) { + _fileCheckers += checkers.allFileCheckers _declarationCheckers += checkers.declarationCheckers _memberDeclarationCheckers += checkers.allMemberDeclarationCheckers + _regularClassCheckers += checkers.allRegularClassCheckers _constructorCheckers += checkers.allConstructorCheckers _controlFlowAnalyserCheckers += checkers.controlFlowAnalyserCheckers } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt new file mode 100644 index 00000000000..bc8ba30199e --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirDeclarationInspector.kt @@ -0,0 +1,146 @@ +/* + * 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 + +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.types.FirErrorTypeRef +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.Name + +private open class RepresentationBuilder { + var receiver = "" + var name = "" + + open fun build() = "[$receiver] $name" +} + +private fun buildRepresentation(init: RepresentationBuilder.() -> Unit): String { + return RepresentationBuilder().apply(init).build() +} + +private class FunctionRepresentationBuilder : RepresentationBuilder() { + var typeArguments = "" + var parameters = "" + + override fun build() = "<$typeArguments> [$receiver] $name ($parameters)" +} + +private fun buildFunctionRepresentation(init: FunctionRepresentationBuilder.() -> Unit): String { + return FunctionRepresentationBuilder().apply(init).build() +} + +private fun ClassId.represent() = packageFqName.asString() + '/' + relativeClassName.asString() + +private fun CallableId.represent() = if (className != null) { + packageName.asString() + '/' + className + '.' + callableName +} else { + packageName.asString() + '/' + callableName +} + +private fun FirTypeRef.represent() = when (this) { + is FirResolvedTypeRef -> type.toString() + is FirErrorTypeRef -> "ERROR" + else -> "?" +} + +private fun FirTypeParameter.represent() = name.asString() + " : " + bounds + .map { it.represent() } + .sorted() + .joinToString() + +private fun FirValueParameter.represent(): String { + val prefix = if (this.isVararg) "vararg " else "" + return prefix + " " + this.returnTypeRef.represent() +} + +private fun FirProperty.represent() = buildRepresentation { + receiver = receiverTypeRef?.represent() ?: "" + name = symbol.callableId.represent() +} + +private fun FirSimpleFunction.represent() = buildFunctionRepresentation { + typeArguments = typeParameters.joinToString { it.represent() } + receiver = receiverTypeRef?.represent() ?: "" + name = symbol.callableId.represent() + parameters = valueParameters.joinToString { it.represent() } +} + +private fun FirTypeAlias.represent() = buildRepresentation { + name = symbol.classId.represent() +} + +private fun FirRegularClass.represent() = buildRepresentation { + name = symbol.classId.represent() +} + +private val NO_NAME_PROVIDED = Name.special("") + +// - see testEnumValuesValueOf. +// it generates a static function that has +// the same signature as the function defined +// explicitly. +// - see tests with `fun () {}`. +// you can't redeclare something that has no name. +private fun FirDeclaration.isCollectable() = when (this) { + is FirSimpleFunction -> source?.kind !is FirFakeSourceElementKind && name != NO_NAME_PROVIDED + is FirRegularClass -> name != NO_NAME_PROVIDED + else -> true +} + +class FirDeclarationInspector { + val otherDeclarations = mutableMapOf>() + val functionDeclarations = mutableMapOf>() + + fun collect(declaration: FirDeclaration) { + if (!declaration.isCollectable()) { + return + } + + if (declaration is FirSimpleFunction) { + return collectFunction(declaration) + } + + val key = when (declaration) { + is FirRegularClass -> declaration.represent() + is FirTypeAlias -> declaration.represent() + is FirProperty -> declaration.represent() + else -> return + } + + var value = otherDeclarations[key] + + if (value == null) { + value = mutableListOf() + otherDeclarations[key] = value + } + + value.add(declaration) + } + + private fun collectFunction(declaration: FirSimpleFunction) { + val key = declaration.represent() + var value = functionDeclarations[key] + + if (value == null) { + value = mutableListOf() + functionDeclarations[key] = value + } + + value.add(declaration) + } + + private fun contains(declaration: FirDeclaration) = when (declaration) { + is FirSimpleFunction -> declaration.represent() in functionDeclarations + is FirRegularClass -> declaration.represent() in otherDeclarations + is FirTypeAlias -> declaration.represent() in otherDeclarations + is FirProperty -> declaration.represent() in otherDeclarations + else -> false + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt index 56f8be27076..822772cb403 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt @@ -12,11 +12,15 @@ abstract class DeclarationCheckers { val EMPTY: DeclarationCheckers = object : DeclarationCheckers() {} } + open val fileCheckers: List = emptyList() open val declarationCheckers: List = emptyList() open val memberDeclarationCheckers: List = emptyList() + open val regularClassCheckers: List = emptyList() open val constructorCheckers: List = emptyList() open val controlFlowAnalyserCheckers: List = emptyList() + internal val allFileCheckers: List get() = fileCheckers + declarationCheckers internal val allMemberDeclarationCheckers: List get() = memberDeclarationCheckers + declarationCheckers + internal val allRegularClassCheckers: List get() = regularClassCheckers + allMemberDeclarationCheckers internal val allConstructorCheckers: List get() = constructorCheckers + allMemberDeclarationCheckers } 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 d257fdc4254..8909110eb20 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 @@ -9,12 +9,17 @@ import org.jetbrains.kotlin.fir.analysis.cfa.FirPropertyInitializationAnalyzer import org.jetbrains.kotlin.fir.analysis.checkers.cfa.FirControlFlowChecker object CommonDeclarationCheckers : DeclarationCheckers() { + override val fileCheckers: List = listOf( + + ) + override val declarationCheckers: List = listOf( FirAnnotationClassDeclarationChecker, FirModifierChecker, FirManyCompanionObjectsChecker, FirLocalEntityNotAllowedChecker, FirTypeParametersInObjectChecker, + FirConflictsChecker, ) override val memberDeclarationCheckers: List = listOf( @@ -26,6 +31,10 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirPrimaryConstructorRequiredForDataClassChecker, ) + override val regularClassCheckers: List = listOf( + + ) + override val constructorCheckers: List = listOf( FirConstructorAllowedChecker, ) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt new file mode 100644 index 00000000000..a235e4583c5 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt @@ -0,0 +1,67 @@ +/* + * 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.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationInspector +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.FirFile +import org.jetbrains.kotlin.fir.declarations.FirRegularClass + +object FirConflictsChecker : FirBasicDeclarationChecker() { + override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + val inspector = FirDeclarationInspector() + + when (declaration) { + is FirFile -> checkFile(declaration, inspector) + is FirRegularClass -> checkRegularClass(declaration, inspector) + else -> return + } + + inspector.functionDeclarations.forEachNonSingle { it, hint -> + reporter.reportConflictingOverloads(it.source, hint) + } + + inspector.otherDeclarations.forEachNonSingle { it, hint -> + reporter.reportConflictingDeclarations(it.source, hint) + } + } + + private fun Map>.forEachNonSingle(action: (FirDeclaration, String) -> Unit) { + for (value in values) { + if (value.size > 1) { + val hint = value.joinToString { that -> that.toString() } + + value.forEach { + action(it, hint) + } + } + } + } + + private fun checkFile(declaration: FirFile, inspector: FirDeclarationInspector) { + for (it in declaration.declarations) { + inspector.collect(it) + } + } + + private fun checkRegularClass(declaration: FirRegularClass, inspector: FirDeclarationInspector) { + for (it in declaration.declarations) { + inspector.collect(it) + } + } + + private fun DiagnosticReporter.reportConflictingOverloads(source: FirSourceElement?, declarations: String) { + source?.let { report(FirErrors.CONFLICTING_OVERLOADS.on(it, declarations)) } + } + + private fun DiagnosticReporter.reportConflictingDeclarations(source: FirSourceElement?, declarations: String) { + source?.let { report(FirErrors.REDECLARATION.on(it, declarations)) } + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationChecker.kt index ba406e8133e..662a6926f37 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationChecker.kt @@ -7,15 +7,14 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.declarations.FirConstructor -import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.declarations.* abstract class FirDeclarationChecker { abstract fun check(declaration: D, context: CheckerContext, reporter: DiagnosticReporter) - } +typealias FirFileChecker = FirDeclarationChecker typealias FirBasicDeclarationChecker = FirDeclarationChecker typealias FirMemberDeclarationChecker = FirDeclarationChecker +typealias FirRegularClassChecker = FirDeclarationChecker typealias FirConstructorChecker = FirDeclarationChecker diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirModifierChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirModifierChecker.kt index bd022424738..a2ef26e346c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirModifierChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirModifierChecker.kt @@ -14,10 +14,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.getModifierList import org.jetbrains.kotlin.fir.analysis.checkers.source import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens.* @@ -167,6 +164,8 @@ object FirModifierChecker : FirBasicDeclarationChecker() { } override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration is FirFile) return + val source = declaration.source ?: return if (!isDeclarationMappedToSourceCorrectly(declaration, source)) return if (context.containingDeclarations.last() is FirDefaultPropertyAccessor) return diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt index 45b8d192b48..f3f5835e166 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt @@ -17,12 +17,16 @@ class DeclarationCheckersDiagnosticComponent( ) : AbstractDiagnosticCollectorComponent(collector) { private val checkers = session.checkersComponent.declarationCheckers + override fun visitFile(file: FirFile, data: CheckerContext) { + runCheck { checkers.fileCheckers.check(file, data, it) } + } + override fun visitProperty(property: FirProperty, data: CheckerContext) { runCheck { checkers.memberDeclarationCheckers.check(property, data, it) } } override fun visitRegularClass(regularClass: FirRegularClass, data: CheckerContext) { - runCheck { checkers.memberDeclarationCheckers.check(regularClass, data, it) } + runCheck { checkers.regularClassCheckers.check(regularClass, data, it) } } override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: CheckerContext) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 9f94c736e72..7f6d459c467 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_CLASS_ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ASSIGN_OPERATOR_AMBIGUITY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.BREAK_OR_CONTINUE_OUTSIDE_A_LOOP +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_OVERLOADS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_CONSTRUCTOR_DELEGATION_CALL @@ -65,6 +66,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROJECTION_ON_NON import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_IMPLICIT_TYPES import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_SUPERTYPES +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDECLARATION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_MODIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REPEATED_MODIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RETURN_NOT_ALLOWED @@ -193,6 +195,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { // Redeclarations map.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class") + map.put(CONFLICTING_OVERLOADS, "Conflicting overloads: {0}", TO_STRING) // * + map.put(REDECLARATION, "Conflicting declarations: {0}", TO_STRING) // * // Invalid local declarations map.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", TO_STRING) // + 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 c763a1e2f40..daf6aabef6e 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 @@ -118,6 +118,8 @@ object FirErrors { // Redeclarations val MANY_COMPANION_OBJECTS by error0() + val CONFLICTING_OVERLOADS by error1() + val REDECLARATION by error1() // Invalid local declarations val LOCAL_OBJECT_NOT_ALLOWED by error1() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt index e00d55e4216..e653e332dfc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.fir.symbols.StandardClassIds fun ConeTypeProjection.createArrayOf(nullable: Boolean = false): ConeKotlinType { if (this is ConeKotlinTypeProjection) { val type = type.lowerBoundIfFlexible() - if (type is ConeClassLikeType) { + if (type is ConeClassLikeType && type.nullability != ConeNullability.NULLABLE) { val classId = type.lookupTag.classId val primitiveArrayId = StandardClassIds.primitiveArrayTypeByElementType[classId] ?: StandardClassIds.unsignedArrayTypeByElementType[classId] diff --git a/compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt b/compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt index b4b7339b434..93b631ec9ae 100644 --- a/compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt +++ b/compiler/testData/codegen/box/unsignedTypes/varargsOfUnsignedTypes.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME diff --git a/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt b/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt index 6a3c83fa9cb..bacf3f33b28 100644 --- a/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/ClassObjects.fir.kt @@ -2,10 +2,10 @@ package Jet86 class A { - companion object { + companion object { val x = 1 } - companion object { + companion object { val x = 1 } } diff --git a/compiler/testData/diagnostics/tests/classObjects/classObjectRedeclaration.fir.kt b/compiler/testData/diagnostics/tests/classObjects/classObjectRedeclaration.fir.kt index 564c96200af..1136f288fc8 100644 --- a/compiler/testData/diagnostics/tests/classObjects/classObjectRedeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/classObjects/classObjectRedeclaration.fir.kt @@ -2,19 +2,19 @@ package test class A { - object Companion + object Companion - companion object + companion object } class B { - companion object Named + companion object Named - object Named + object Named } class C { - class Named + class Named - companion object Named + companion object Named } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt index 791c7e10057..5eccbe99833 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER data class A(val x: Int, val y: String) { - fun copy(x: Int, y: String) = x - fun copy(x: Int, y: String) = A(x, y) + fun copy(x: Int, y: String) = x + fun copy(x: Int, y: String) = A(x, y) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.fir.kt b/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.fir.kt index 798f24affcf..01c1f9aead0 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.fir.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/repeatedProperties.fir.kt @@ -1,9 +1,9 @@ -data class A1(val x: Int, val y: String, val x: Int) { +data class A1(val x: Int, val y: String, val x: Int) { val z = "" } -data class A2(val x: Int, val y: String) { - val x = "" +data class A2(val x: Int, val y: String) { + val x = "" } -data class A3(val :Int, val : Int) +data class A3(val :Int, val : Int) diff --git a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt index b6c3498867d..049a47d1388 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt @@ -7,8 +7,8 @@ class MyClass { class MyClass2 {} -fun MyClass2.component1() = 1.2 -fun MyClass2.component1() = 1.3 +fun MyClass2.component1() = 1.2 +fun MyClass2.component1() = 1.3 fun test(mc1: MyClass, mc2: MyClass2) { val (a, b) = mc1 diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt index b9a927bbe78..11046074966 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt @@ -1,6 +1,6 @@ class A { - operator fun component1() = 1 - operator fun component1() = 1 + operator fun component1() = 1 + operator fun component1() = 1 operator fun component2() = 1 } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt index 91ae4434e08..4905cc7020e 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.fir.kt @@ -3,10 +3,10 @@ // KT-3464 Front-end shouldn't allow override modifier in class declaration override class A { - override companion object {} - open companion object {} - abstract companion object {} - final companion object {} + override companion object {} + open companion object {} + abstract companion object {} + final companion object {} } override object B1 {} diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.fir.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.fir.kt index 653071684ab..51abf600c1a 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.fir.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.fir.kt @@ -1,5 +1,5 @@ class C { - companion object {} + companion object {} - val Companion = C + val Companion = C } diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.fir.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.fir.kt index 4831e5ca1f0..f7e865b27d5 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.fir.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.fir.kt @@ -1,8 +1,8 @@ class B { - companion object A { + companion object A { } - val A = this + val A = this } class C { diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.fir.kt index 43ee1c7910f..74680a72759 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/captureFromNullableTypeVariable.fir.kt @@ -10,5 +10,5 @@ fun test1(a: Array) { fun test2(vararg a: Int?) { val list = a.filterNotNull() - list checkType { _>() } + list checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.fir.kt b/compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.fir.kt index d641299f7b2..16901d9e259 100644 --- a/compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/binaryExpressions/mathOperations.fir.kt @@ -15,15 +15,15 @@ inline operator fun @ExtensionFunctionType Function2.plus(p: this - p } -inline fun inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) { +inline fun inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) { s + s ext + ext -} +} -inline fun inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) { +inline fun inlineFunWithInvoke(s: (p: T) -> U, ext: T.(p: U) -> V) { s + s ext + ext -} +} inline fun Function1.submit() { this + this diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.fir.kt index e51224eba3e..d526eebfdb5 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/expectDeclarationWithWeakIncompatibilities.fir.kt @@ -23,6 +23,6 @@ actual var s: String = "value" fun foo2(): Int = 0 -actual class Foo3 +actual class Foo3 -class Foo3 +class Foo3 diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.fir.kt deleted file mode 100644 index c7b164c9192..00000000000 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -// !LANGUAGE: +MultiPlatformProjects -// MODULE: m1-common -// FILE: common.kt - -expect fun foo() -expect fun foo() - -expect fun foo(x: Int) diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt index f60a780381a..9932503cc86 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingHeaderDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +MultiPlatformProjects // MODULE: m1-common // FILE: common.kt diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt index da6dad9b6c2..3fc939f994e 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt @@ -7,11 +7,11 @@ expect fun foo() // MODULE: m2-jvm(m1-common) // FILE: jvm.kt -actual fun foo() {} -actual fun foo() {} +actual fun foo() {} +actual fun foo() {} // MODULE: m3-js(m1-common) // FILE: js.kt -actual fun foo() {} -actual fun foo() {} +actual fun foo() {} +actual fun foo() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt index dd4f3f56bde..354cb79554c 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt @@ -2,8 +2,8 @@ // MODULE: m1-common // FILE: common.kt -expect fun foo() +expect fun foo() -expect fun foo() {} +expect fun foo() {} expect fun bar() {} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt index e2f8356240f..7ab306aa4ba 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt @@ -1,6 +1,6 @@ class A { - fun a(a: Int): Int = 0 + fun a(a: Int): Int = 0 - fun a(a: Int) { - } + fun a(a: Int) { + } } diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt index 9eb073bf03a..ccecc8e1f00 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt @@ -1,7 +1,7 @@ package qwertyuiop -fun c(s: String) { -} +fun c(s: String) { +} -fun c(s: String) { -} +fun c(s: String) { +} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt index 559f0c9ab01..a7fa2b5bc69 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt @@ -1,5 +1,5 @@ package extensionFunctions -fun Int.qwe(a: Float) = 1 +fun Int.qwe(a: Float) = 1 -fun Int.qwe(a: Float) = 2 +fun Int.qwe(a: Float) = 2 diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt index 93a3bbb7069..756a107d8fd 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt @@ -1,7 +1,7 @@ class A() { - fun b() { - } + fun b() { + } - fun b() { - } + fun b() { + } } diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalValsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalValsInClass.fir.kt index 56352d941f3..2ca7e2c8faf 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalValsInClass.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalValsInClass.fir.kt @@ -1,4 +1,4 @@ class Aaa() { - val a = 1 - val a = 1 + val a = 1 + val a = 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsValsDifferentTypeInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsValsDifferentTypeInClass.fir.kt index da5d63eba02..876bcfe753b 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsValsDifferentTypeInClass.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsValsDifferentTypeInClass.fir.kt @@ -1,4 +1,4 @@ class Aaa() { - val a = 1 - val a = "" + val a = 1 + val a = "" } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt b/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt index 55e95f4bc38..1aef2b3ca48 100644 --- a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt @@ -1,8 +1,8 @@ import java.io.Serializable interface Test1 { - fun foo(t: T) where T : Cloneable, T : Serializable - fun foo(t: T) where T : Serializable, T : Cloneable + fun foo(t: T) where T : Cloneable, T : Serializable + fun foo(t: T) where T : Serializable, T : Cloneable } @@ -10,6 +10,6 @@ interface I1 interface I2 : I1 interface Test2 { - fun foo(t: T) where T : I1, T : I2 - fun foo(t: T) where T : I2, T : I1 + fun foo(t: T) where T : I1, T : I2 + fun foo(t: T) where T : I2, T : I1 } diff --git a/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt b/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt index 3a5b3e7b8e1..be33444fcb7 100644 --- a/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt +++ b/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt @@ -3,6 +3,6 @@ interface Some { } class SomeImpl : Some { - override fun test() {} - override fun test() {} + override fun test() {} + override fun test() {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.fir.kt index 4a0c17cc96f..0641d9932d6 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/ConflictingExtensionProperties.fir.kt @@ -1,4 +1,4 @@ package foo -val Int.foo: Int get() = 2 -val Int.foo: Int get() = 3 +val Int.foo: Int get() = 2 +val Int.foo: Int get() = 3 diff --git a/compiler/testData/diagnostics/tests/redeclarations/PropertyAndInnerClass.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/PropertyAndInnerClass.fir.kt index 897272f303d..2e7f81b2f2c 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/PropertyAndInnerClass.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/PropertyAndInnerClass.fir.kt @@ -1,13 +1,13 @@ public class A() { - public val FOO: String = "test" + public val FOO: String = "test" - public class FOO() { } + public class FOO() { } } public class B() { companion object { - public val FOO: String = "test" + public val FOO: String = "test" - public class FOO() { } + public class FOO() { } } } diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationInDefaultObject.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationInDefaultObject.fir.kt index dbacb0355db..fafb3741ebb 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationInDefaultObject.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationInDefaultObject.fir.kt @@ -1,6 +1,6 @@ class A { companion object B { - class G - val G = 1 + class G + val G = 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt index 64d63d375b5..fa478cd835d 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // KT-9733 No error shown for 2 "main" functions in the same file -fun main(args: Array) {} -fun main(args: Array) {} \ No newline at end of file +fun main(args: Array) {} +fun main(args: Array) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/Redeclarations.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/Redeclarations.fir.kt index f73cefbdb20..9638c6eaa1c 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/Redeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/Redeclarations.fir.kt @@ -1,14 +1,14 @@ // FILE: f.kt package redeclarations - object A { + object A { val x : Int = 0 val A = 1 } - class A {} + class A {} - val A = 1 + val A = 1 // FILE: f.kt package redeclarations.A diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationsInObjects.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationsInObjects.fir.kt index 69d28fec063..dd67dab11f3 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationsInObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationsInObjects.fir.kt @@ -1,9 +1,9 @@ // !DIAGNOSTICS: -DUPLICATE_CLASS_NAMES // KT-3525 object B { - class C - class C + class C + class C - val a : Int = 1 - val a : Int = 1 + val a : Int = 1 + val a : Int = 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt index 048c5bf2a5c..faa8c989be2 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt @@ -14,16 +14,16 @@ private val invalidProp0 = 1 fun useInvalidFun0() = invalidFun0() fun useInvalidProp0() = invalidProp0 -private fun invalidFun1() {} -private fun invalidFun1() {} +private fun invalidFun1() {} +private fun invalidFun1() {} -private fun invalidFun2() {} -public fun invalidFun2() {} +private fun invalidFun2() {} +public fun invalidFun2() {} public fun invalidFun3() {} -private fun invalidFun4() {} -public fun invalidFun4() {} +private fun invalidFun4() {} +public fun invalidFun4() {} public fun validFun2(a: A) = a public fun validFun2(b: B) = b diff --git a/compiler/testData/diagnostics/tests/redeclarations/TopLevelPropertyVsClassifier.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/TopLevelPropertyVsClassifier.fir.kt index d34d5646823..35619073911 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/TopLevelPropertyVsClassifier.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/TopLevelPropertyVsClassifier.fir.kt @@ -1,13 +1,13 @@ -val Test1 = null -class Test1 +val Test1 = null +class Test1 -val Test2 = null -interface Test2 +val Test2 = null +interface Test2 -val Test3 = null -object Test3 +val Test3 = null +object Test3 -val Test4 = null -class Test4 -interface Test4 -object Test4 \ No newline at end of file +val Test4 = null +class Test4 +interface Test4 +object Test4 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsClass.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsClass.fir.kt index 6865692e7d4..453f0be155c 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsClass.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsClass.fir.kt @@ -1,17 +1,17 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY // FILE: file1.kt -class SomeClass +class SomeClass -typealias SomeClass = Any -typealias SomeClass = Any -typealias SomeClass = Any +typealias SomeClass = Any +typealias SomeClass = Any +typealias SomeClass = Any class Outer { - class Nested + class Nested - typealias Nested = Any - typealias Nested = Any - typealias Nested = Any + typealias Nested = Any + typealias Nested = Any + typealias Nested = Any } // FILE: file2.kt diff --git a/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsProperty.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsProperty.fir.kt index a52cf540780..0f13bcbbeca 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsProperty.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/TypeAliasVsProperty.fir.kt @@ -1,13 +1,13 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY // FILE: file1.kt -typealias Test = String +typealias Test = String -val Test = 42 +val Test = 42 class Outer { - typealias Test = String + typealias Test = String - val Test = 42 + val Test = 42 } typealias Test2 = String diff --git a/compiler/testData/diagnostics/tests/redeclarations/kt2438.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/kt2438.fir.kt index e559d20a8b6..b580e859b03 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/kt2438.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/kt2438.fir.kt @@ -4,19 +4,19 @@ package kt2438 class B { - class C - class C + class C + class C } class A { - class B + class B companion object { - class B - class B + class B + class B } - class B + class B } diff --git a/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt index 167ac8dbfd7..d5c756feafe 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt @@ -1,37 +1,37 @@ -val a : Int = 1 -val a : Int = 1 -val a : Int = 1 +val a : Int = 1 +val a : Int = 1 +val a : Int = 1 -val b : Int = 1 -val b : Int = 1 -val b : Int = 1 -val b : Int = 1 +val b : Int = 1 +val b : Int = 1 +val b : Int = 1 +val b : Int = 1 -fun foo() {} // and here too -fun foo() {} // and here -fun foo() {} // and here -fun foo() {} // and here +fun foo() {} // and here too +fun foo() {} // and here +fun foo() {} // and here +fun foo() {} // and here -fun bar() {} // and here -fun bar() {} // and here -fun bar() {} // and here +fun bar() {} // and here +fun bar() {} // and here +fun bar() {} // and here class A { - val a : Int = 1 - val a : Int = 1 - val a : Int = 1 + val a : Int = 1 + val a : Int = 1 + val a : Int = 1 - val b : Int = 1 - val b : Int = 1 - val b : Int = 1 - val b : Int = 1 + val b : Int = 1 + val b : Int = 1 + val b : Int = 1 + val b : Int = 1 - fun foo() {} // and here too - fun foo() {} // and here - fun foo() {} // and here - fun foo() {} // and here + fun foo() {} // and here too + fun foo() {} // and here + fun foo() {} // and here + fun foo() {} // and here - fun bar() {} // and here - fun bar() {} // and here - fun bar() {} // and here + fun bar() {} // and here + fun bar() {} // and here + fun bar() {} // and here } diff --git a/compiler/testData/diagnostics/tests/regressions/Jet11.fir.kt b/compiler/testData/diagnostics/tests/regressions/Jet11.fir.kt index 10db1b15a24..5f95d00270d 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet11.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet11.fir.kt @@ -1,4 +1,4 @@ // JET-11 Redeclaration & Forward reference for classes cause an exception -open class NoC +open class NoC class NoC1 : NoC() -open class NoC +open class NoC diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt index e44a56bef9b..e19700c8231 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt @@ -3,32 +3,32 @@ package c fun z(view: () -> Unit) {} -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } class x() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/redeclarationsOfConstructorsIgnored.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/redeclarationsOfConstructorsIgnored.fir.kt index b5b147b0085..6df18e93ac3 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/redeclarationsOfConstructorsIgnored.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/redeclarationsOfConstructorsIgnored.fir.kt @@ -1,7 +1,7 @@ -class A -class A { +class A +class A { constructor() -} +} class B class Outer { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt index 93bb56959b7..93b532a59ec 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt @@ -1,15 +1,15 @@ // FILE: main.kt interface A { - suspend fun foo() - fun foo() + suspend fun foo() + fun foo() } interface B : A { - suspend override fun foo() { + suspend override fun foo() { - } + } - override fun foo() { + override fun foo() { - } + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt index 71be470264b..acb58ed66d0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt @@ -1,13 +1,13 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE // !WITH_NEW_INFERENCE -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution -public fun Iterable.contains1(element: T): Int = null!! +public fun Iterable.contains1(element: T): Int = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!! +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!! fun test() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index f24106e995a..68afa34a75e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -2,13 +2,13 @@ // !WITH_NEW_INFERENCE // !LANGUAGE: -NonStrictOnlyInputTypesChecks -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution -public fun Iterable.contains1(element: T): Int = null!! +public fun Iterable.contains1(element: T): Int = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @JvmName("getAny") diff --git a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.4.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.4.fir.kt index 9fed5a61016..e29283c0f0c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.4.fir.kt @@ -54,9 +54,9 @@ class Case2() { * TESTCASE NUMBER: 3 * NOTE: check abstract member cannot be accessed directly */ -class Case3(override val boo: String) : BaseCase3() { +class Case3(override val boo: String) : BaseCase3() { override val zoo: String = super.foo() - override val boo: String = super.boo + override val boo: String = super.boo override val value: String = super.zoo val hoo: String = super.zoo diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-14/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-14/neg/1.1.fir.kt index 7360d94c8c7..0f5b5e2ae1c 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-14/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-14/neg/1.1.fir.kt @@ -18,7 +18,7 @@ class Case2() { fun foo(vararg x: Int?): Unit = TODO() // (1.2) fun case(){ - foo(1, 1) + foo(1, 1) } } // TESTCASE NUMBER: 3 @@ -27,7 +27,7 @@ class Case3() { fun foo(vararg x: Int?): Unit = TODO() // (1.2) fun case(){ - foo(1, 1) + foo(1, 1) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt index d525155afb0..9d62f586de0 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt @@ -5,7 +5,7 @@ // TESTCASE NUMBER: 1 fun case_1(vararg x: Int?) { if (x != null) { - x + & kotlin.Array")!>x x[0] } } @@ -21,8 +21,8 @@ fun case_2(vararg x: Int?) { x[0].also { if (it != null) { - it - it.inv() + it + it.inv() } } }