diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/forLoopChecker.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/forLoopChecker.kt index 24cdb140ab5..658e51e708a 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/forLoopChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/diagnostics/forLoopChecker.kt @@ -101,9 +101,9 @@ fun test( for (i in notRange2); for (i in notRange3); for (i in notRange4); - for (i in notRange5); + for (i in notRange5); for (i in notRange6); - for (i in notRange7); + for (i in notRange7); for (i in notRange8); for (i in notRange9); for (i in range0); diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt index 29c9a309f4c..e9ea2e8ff84 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt @@ -28,6 +28,8 @@ fun main(args: Array) { alias("VariableAssignmentChecker") alias("TryExpressionChecker") alias("WhenExpressionChecker") + alias("LoopExpressionChecker") + alias("LogicExpressionChecker") alias("ReturnExpressionChecker") alias("BlockChecker") alias("AnnotationCallChecker") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ComposedExpressionCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ComposedExpressionCheckers.kt index 494a6aea306..d4cfbf10f69 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ComposedExpressionCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ComposedExpressionCheckers.kt @@ -25,6 +25,10 @@ class ComposedExpressionCheckers : ExpressionCheckers() { get() = _tryExpressionCheckers override val whenExpressionCheckers: Set get() = _whenExpressionCheckers + override val loopExpressionCheckers: Set + get() = _loopExpressionCheckers + override val logicExpressionCheckers: Set + get() = _logicExpressionCheckers override val returnExpressionCheckers: Set get() = _returnExpressionCheckers override val blockCheckers: Set @@ -56,6 +60,8 @@ class ComposedExpressionCheckers : ExpressionCheckers() { private val _variableAssignmentCheckers: MutableSet = mutableSetOf() private val _tryExpressionCheckers: MutableSet = mutableSetOf() private val _whenExpressionCheckers: MutableSet = mutableSetOf() + private val _loopExpressionCheckers: MutableSet = mutableSetOf() + private val _logicExpressionCheckers: MutableSet = mutableSetOf() private val _returnExpressionCheckers: MutableSet = mutableSetOf() private val _blockCheckers: MutableSet = mutableSetOf() private val _annotationCallCheckers: MutableSet = mutableSetOf() @@ -77,6 +83,8 @@ class ComposedExpressionCheckers : ExpressionCheckers() { _variableAssignmentCheckers += checkers.variableAssignmentCheckers _tryExpressionCheckers += checkers.tryExpressionCheckers _whenExpressionCheckers += checkers.whenExpressionCheckers + _loopExpressionCheckers += checkers.loopExpressionCheckers + _logicExpressionCheckers += checkers.logicExpressionCheckers _returnExpressionCheckers += checkers.returnExpressionCheckers _blockCheckers += checkers.blockCheckers _annotationCallCheckers += checkers.annotationCallCheckers diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ExpressionCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ExpressionCheckers.kt index db1cb7eb3a5..407b36f74e9 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ExpressionCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/ExpressionCheckers.kt @@ -23,6 +23,8 @@ abstract class ExpressionCheckers { open val variableAssignmentCheckers: Set = emptySet() open val tryExpressionCheckers: Set = emptySet() open val whenExpressionCheckers: Set = emptySet() + open val loopExpressionCheckers: Set = emptySet() + open val logicExpressionCheckers: Set = emptySet() open val returnExpressionCheckers: Set = emptySet() open val blockCheckers: Set = emptySet() open val annotationCallCheckers: Set = emptySet() @@ -42,6 +44,8 @@ abstract class ExpressionCheckers { @CheckersComponentInternal internal val allVariableAssignmentCheckers: Set get() = variableAssignmentCheckers + basicExpressionCheckers @CheckersComponentInternal internal val allTryExpressionCheckers: Set get() = tryExpressionCheckers + basicExpressionCheckers @CheckersComponentInternal internal val allWhenExpressionCheckers: Set get() = whenExpressionCheckers + basicExpressionCheckers + @CheckersComponentInternal internal val allLoopExpressionCheckers: Set get() = loopExpressionCheckers + basicExpressionCheckers + @CheckersComponentInternal internal val allLogicExpressionCheckers: Set get() = logicExpressionCheckers + basicExpressionCheckers @CheckersComponentInternal internal val allReturnExpressionCheckers: Set get() = returnExpressionCheckers + basicExpressionCheckers @CheckersComponentInternal internal val allBlockCheckers: Set get() = blockCheckers + basicExpressionCheckers @CheckersComponentInternal internal val allAnnotationCallCheckers: Set get() = annotationCallCheckers + basicExpressionCheckers diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExpressionCheckerAliases.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExpressionCheckerAliases.kt index 18a4fba256d..4dd35550f97 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExpressionCheckerAliases.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExpressionCheckerAliases.kt @@ -12,12 +12,14 @@ package org.jetbrains.kotlin.fir.analysis.checkers.expression import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirBinaryLogicExpression import org.jetbrains.kotlin.fir.expressions.FirBlock import org.jetbrains.kotlin.fir.expressions.FirCheckNotNullCall import org.jetbrains.kotlin.fir.expressions.FirElvisExpression import org.jetbrains.kotlin.fir.expressions.FirEqualityOperatorCall import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirGetClassCall +import org.jetbrains.kotlin.fir.expressions.FirLoop import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.FirReturnExpression @@ -35,6 +37,8 @@ typealias FirFunctionCallChecker = FirExpressionChecker typealias FirVariableAssignmentChecker = FirExpressionChecker typealias FirTryExpressionChecker = FirExpressionChecker typealias FirWhenExpressionChecker = FirExpressionChecker +typealias FirLoopExpressionChecker = FirExpressionChecker +typealias FirLogicExpressionChecker = FirExpressionChecker typealias FirReturnExpressionChecker = FirExpressionChecker typealias FirBlockChecker = FirExpressionChecker typealias FirAnnotationCallChecker = FirExpressionChecker diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt index 7afd0371317..8e88d2de75d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt @@ -568,4 +568,13 @@ fun checkTypeMismatch( reporter.report(diagnosticFactory.on(source, lValueType, rValueType), context) } } -} \ No newline at end of file +} + +internal fun checkCondition(condition: FirExpression, context: CheckerContext, reporter: DiagnosticReporter) { + val coneType = condition.typeRef.coneType.lowerBoundIfFlexible() + if (coneType !is ConeKotlinErrorType && + !coneType.isSubtypeOf(context.session.typeContext, context.session.builtinTypes.booleanType.type) + ) { + reporter.reportOn(condition.source, FirErrors.CONDITION_TYPE_MISMATCH, coneType, context) + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLogicExpressionTypeChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLogicExpressionTypeChecker.kt new file mode 100644 index 00000000000..1006eac3f49 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLogicExpressionTypeChecker.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2021 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.expression + +import org.jetbrains.kotlin.fir.analysis.checkers.checkCondition +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.expressions.FirBinaryLogicExpression + +object FirLogicExpressionTypeChecker : FirLogicExpressionChecker() { + override fun check(expression: FirBinaryLogicExpression, context: CheckerContext, reporter: DiagnosticReporter) { + checkCondition(expression.leftOperand, context, reporter) + checkCondition(expression.rightOperand, context, reporter) + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLoopConditionChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLoopConditionChecker.kt new file mode 100644 index 00000000000..f25c76db2d7 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirLoopConditionChecker.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2021 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.expression + +import org.jetbrains.kotlin.fir.analysis.checkers.checkCondition +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.withSuppressedDiagnostics +import org.jetbrains.kotlin.fir.expressions.FirErrorLoop +import org.jetbrains.kotlin.fir.expressions.FirLoop + +object FirLoopConditionChecker : FirLoopExpressionChecker() { + override fun check(expression: FirLoop, context: CheckerContext, reporter: DiagnosticReporter) { + if (expression is FirErrorLoop) return + val condition = expression.condition + withSuppressedDiagnostics(condition, context) { + checkCondition(condition, context, reporter) + } + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirWhenConditionChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirWhenConditionChecker.kt new file mode 100644 index 00000000000..0bf30b8bb65 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirWhenConditionChecker.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2021 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.expression + +import org.jetbrains.kotlin.fir.analysis.checkers.checkCondition +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.withSuppressedDiagnostics +import org.jetbrains.kotlin.fir.expressions.FirWhenExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition + +object FirWhenConditionChecker : FirWhenExpressionChecker() { + override fun check(expression: FirWhenExpression, context: CheckerContext, reporter: DiagnosticReporter) { + for (branch in expression.branches) { + val condition = branch.condition + if (condition is FirElseIfTrueCondition) continue + withSuppressedDiagnostics(condition, context) { + checkCondition(condition, context, reporter) + } + } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt index 34aa3c91655..a7bbf90f792 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirExpressionChecker import org.jetbrains.kotlin.fir.analysis.checkersComponent -import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.* @@ -63,8 +62,20 @@ class ExpressionCheckersDiagnosticComponent( checkers.allWhenExpressionCheckers.check(whenExpression, data, reporter) } + override fun visitWhileLoop(whileLoop: FirWhileLoop, data: CheckerContext) { + checkers.allLoopExpressionCheckers.check(whileLoop, data, reporter) + } + + override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: CheckerContext) { + checkers.allLoopExpressionCheckers.check(doWhileLoop, data, reporter) + } + + override fun visitErrorLoop(errorLoop: FirErrorLoop, data: CheckerContext) { + checkers.allLoopExpressionCheckers.check(errorLoop, data, reporter) + } + override fun visitBinaryLogicExpression(binaryLogicExpression: FirBinaryLogicExpression, data: CheckerContext) { - checkers.allBasicExpressionCheckers.check(binaryLogicExpression, data, reporter) + checkers.allLogicExpressionCheckers.check(binaryLogicExpression, data, reporter) } override fun visitArrayOfCall(arrayOfCall: FirArrayOfCall, data: CheckerContext) { diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt index a478c46a14d..4f5f86c0a43 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt @@ -56,7 +56,18 @@ object CommonExpressionCheckers : ExpressionCheckers() { override val whenExpressionCheckers: Set get() = setOf( - FirExhaustiveWhenChecker + FirExhaustiveWhenChecker, + FirWhenConditionChecker, + ) + + override val loopExpressionCheckers: Set + get() = setOf( + FirLoopConditionChecker, + ) + + override val logicExpressionCheckers: Set + get() = setOf( + FirLogicExpressionTypeChecker, ) override val returnExpressionCheckers: Set diff --git a/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt b/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt index 687dae6a3e3..3086aed6ca3 100644 --- a/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt +++ b/compiler/testData/diagnostics/tests/BinaryCallsOnNullableValues.fir.kt @@ -26,7 +26,7 @@ fun f(): Unit { x in 1..2 val y : Boolean? = true - false || y - y && true - y && 1 + false || y + y && true + y && 1 } diff --git a/compiler/testData/diagnostics/tests/ForRangeConventions.fir.kt b/compiler/testData/diagnostics/tests/ForRangeConventions.fir.kt index 1f5ac003d33..4ce159082d3 100644 --- a/compiler/testData/diagnostics/tests/ForRangeConventions.fir.kt +++ b/compiler/testData/diagnostics/tests/ForRangeConventions.fir.kt @@ -82,9 +82,9 @@ fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRa for (i in notRange2); for (i in notRange3); for (i in notRange4); - for (i in notRange5); + for (i in notRange5); for (i in notRange6); - for (i in notRange7); + for (i in notRange7); for (i in notRange8); for (i in range0); for (i in range1); diff --git a/compiler/testData/diagnostics/tests/checkArguments/booleanExpressions.fir.kt b/compiler/testData/diagnostics/tests/checkArguments/booleanExpressions.fir.kt index 4d6dbaa913d..7d0bef6f296 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/booleanExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/booleanExpressions.fir.kt @@ -1,7 +1,7 @@ // !WITH_NEW_INFERENCE fun foo1(b: Boolean, c: Int) { - if (b && c) {} - if (b || c) {} - if (c && b) {} - if (c || b) {} + if (b && c) {} + if (b || c) {} + if (c && b) {} + if (c || b) {} } diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt657.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/kt657.fir.kt index 4e9d18ad852..eb6272ee5a2 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt657.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt657.fir.kt @@ -7,10 +7,10 @@ fun foo() = when { cond1() -> 12 cond2() -> 2 - 4 -> 34 - Pair(1, 2) -> 3 + 4 -> 34 + Pair(1, 2) -> 3 in 1..10 -> 34 - 4 -> 38 + 4 -> 38 is Int -> 33 else -> 34 } diff --git a/compiler/testData/diagnostics/tests/inline/binaryExpressions/andOr.kt b/compiler/testData/diagnostics/tests/inline/binaryExpressions/andOr.kt index d55b86e1e17..726c0f36fde 100644 --- a/compiler/testData/diagnostics/tests/inline/binaryExpressions/andOr.kt +++ b/compiler/testData/diagnostics/tests/inline/binaryExpressions/andOr.kt @@ -1,5 +1,5 @@ // FIR_IDENTICAL -// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -TYPE_MISMATCH +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE -NOTHING_TO_INLINE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -TYPE_MISMATCH -CONDITION_TYPE_MISMATCH inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) { s && ext diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.fir.kt index 352b3c96041..d08d7080d4a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.fir.kt @@ -23,23 +23,23 @@ fun test() { val platformJ = J.staticJ if (platformNN) {} - if (platformN) {} + if (platformN) {} if (platformJ) {} while (platformNN) {} - while (platformN) {} + while (platformN) {} while (platformJ) {} do {} while (platformNN) - do {} while (platformN) + do {} while (platformN) do {} while (platformJ) platformNN && false - platformN && false + platformN && false platformJ && false platformNN || false - platformN || false + platformN || false platformJ || false !platformNN diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt index b1706dd9f02..74823fcc009 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt @@ -12,7 +12,7 @@ fun isString(x: Any?): Boolean { } fun incorrectPartDoesntMatter(x: Any?) { - if (isString(x) && 1) { + if (isString(x) && 1) { x.length } else { diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/conditional-expression/p-6/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/conditional-expression/p-6/neg/1.1.fir.kt index 3dbfcd0cc8f..4327b3e006e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/conditional-expression/p-6/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/conditional-expression/p-6/neg/1.1.fir.kt @@ -26,7 +26,7 @@ import checkSubtype */ fun case1() { val a: Any = true - if (a) { "true" } else "false" + if (a) { "true" } else "false" checkSubtype(a) } @@ -37,7 +37,7 @@ fun case1() { */ fun case2() { val a = JavaContainer.aO - if (a) { "true" } else "false" + if (a) { "true" } else "false" checkSubtype(a) } @@ -54,7 +54,7 @@ public class JavaClassCase3{ fun case3() { val x = JavaClassCase3.id(null) // Nothing! x - val a = if (x) { + val a = if (x) { "NOK" } else "NOK" } diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt index e30431cfb93..f7490adf061 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt @@ -19,13 +19,13 @@ import checkType import check // TESTCASE NUMBER: 0 -fun foo() = run { false && JavaClass.VALUE && throw Exception() } +fun foo() = run { false && JavaClass.VALUE && throw Exception() } // TESTCASE NUMBER: 1 fun case1() { val a: Boolean? = false checkSubtype(a) - val x4 = a && true + val x4 = a && true x4 checkType { check() } } @@ -33,7 +33,7 @@ fun case1() { fun case2() { val a: Any = false a - val x4 = a && true + val x4 = a && true x4 checkType { check() } } @@ -43,7 +43,7 @@ fun case3() { val a2 = JavaClass.VALUE a2 - val x3 = a1 && a2 + val x3 = a1 && a2 x3 x3 checkType { check() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt index 086ec2bf430..8b119912020 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt @@ -19,13 +19,13 @@ import checkType import check // TESTCASE NUMBER: 0 -fun foo() = run { false || JavaClass.VALUE || throw Exception() } +fun foo() = run { false || JavaClass.VALUE || throw Exception() } // TESTCASE NUMBER: 1 fun case1() { val a: Boolean? = false checkSubtype(a) - val x4 = a || true + val x4 = a || true x4 checkType { check() } } @@ -33,7 +33,7 @@ fun case1() { fun case2() { val a: Any = false a - val x4 = a || true + val x4 = a || true x4 checkType { check() } } @@ -43,7 +43,7 @@ fun case3() { val a2 = JavaClass.VALUE a2 - val x3 = a1 || a2 + val x3 = a1 || a2 x3 x3 checkType { check() } diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.1.fir.kt index 38c29ce9916..abf479e0504 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.1.fir.kt @@ -3,12 +3,12 @@ // TESTCASE NUMBER: 1 fun case_1(value_1: Int, value_2: String, value_3: TypesProvider): String { when { - .012f / value_1 -> return "" - "$value_2..." -> return "" - '-' -> return "" - {} -> return "" - value_3.getAny() -> return "" - -10..-1 -> return "" + .012f / value_1 -> return "" + "$value_2..." -> return "" + '-' -> return "" + {} -> return "" + value_3.getAny() -> return "" + -10..-1 -> return "" } return "" diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.2.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.2.fir.kt index f283f98d295..b6bd26175ab 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/p-2/neg/2.2.fir.kt @@ -5,7 +5,7 @@ fun case_1(value_1: TypesProvider) { when { getBoolean(), value_1.getBoolean() -> return value_1.getBoolean() && getBoolean(), getLong() == 1000L -> return - Out(), getLong(), {}, Any(), throw Exception() -> return + Out(), getLong(), {}, Any(), throw Exception() -> return } return diff --git a/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-3/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-3/neg/1.1.fir.kt index f6d1b161111..7796e06f34b 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-3/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/do-while-loop-statement/p-3/neg/1.1.fir.kt @@ -5,19 +5,19 @@ // TESTCASE NUMBER: 1 fun case1() { do { - } while ("boo") + } while ("boo") } // TESTCASE NUMBER: 2 fun case2() { val condition: Any = true do { - } while (condition) + } while (condition) } // TESTCASE NUMBER: 3 fun case3() { val condition: Boolean? = true do { - } while (condition) + } while (condition) } diff --git a/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-3/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-3/neg/1.1.fir.kt index 8bd33023462..bf83a6f0218 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-3/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/statements/loop-statements/while-loop-statement/p-3/neg/1.1.fir.kt @@ -6,13 +6,13 @@ // TESTCASE NUMBER: 1 fun case1() { val condition: Any = true - while (condition && "true") { + while (condition && "true") { } } // TESTCASE NUMBER: 2 fun case2() { val condition: Boolean? = true - while (condition) { + while (condition) { } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt index 89aaeaf3d42..687fd142356 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt @@ -108,7 +108,7 @@ fun case_11(x: Any?) { * ISSUES: KT-30376 */ fun case_12(x: Any?) { - if (x!! as Boolean?) { + if (x!! as Boolean?) { x.not() select(x).not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt index 4d0ec43070a..8ee66a5381c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt @@ -613,7 +613,7 @@ fun case_30(a: ((Float) -> Int?)?, b: Float?) { // TESTCASE NUMBER: 31 fun case_31(z1: Boolean?, z: Nothing?) { - if (false || EnumClassWithNullableProperty.A.prop_1 != z && z1 !== z && z1) { + if (false || EnumClassWithNullableProperty.A.prop_1 != z && z1 !== z && z1) { EnumClassWithNullableProperty.A.prop_1 EnumClassWithNullableProperty.A.prop_1.equals(null) EnumClassWithNullableProperty.A.prop_1.propT