From d7399ed1cf6fe5a31061dd9543230b5cb84b500c Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 23 Nov 2022 13:19:43 +0100 Subject: [PATCH] K2: Avoid losing diagnostics for synthetic calls Some of the changed tests may duplicate other existing diagnostics, but that should not be reason not to report them at all. There might be another job to be done to avoid diagnostic duplications --- .../transformers/FirSyntheticCallGenerator.kt | 4 +++- .../org/jetbrains/kotlin/KtSourceElement.kt | 4 +++- .../tests/QualifiedExpressions.fir.kt | 4 ++-- ...lectionLiteralsOutsideOfAnnotations.fir.kt | 20 +++++++++++++++++ .../collectionLiteralsOutsideOfAnnotations.kt | 1 - .../tests/collectionLiterals/kt34515.fir.kt | 4 ++-- .../specialConstructsAndPlatformTypes.fir.kt | 2 +- .../controlStructuresErrors.fir.kt | 4 ++-- .../specialCallsWithCallableReferences.fir.kt | 10 ++++----- ...erencesDontCareTypeInBlockExression.fir.kt | 4 ++-- ...allsWithCallableReferencesErrorType.fir.kt | 2 +- ...ableReferencesErrorTypeUnrestricted.fir.kt | 2 +- ...sWithCallableReferencesUnrestricted.fir.kt | 10 ++++----- .../inference/extensionLambdasAndArrow.fir.kt | 6 ++--- .../inference/regressions/kt33629.fir.kt | 4 ++-- .../inference/regressions/kt35943.fir.kt | 2 +- .../inference/regressions/kt36342.fir.kt | 14 ++++++------ .../tests/inference/regressions/kt948.fir.kt | 2 +- ...InformationErrorsOnBlockExpressions.fir.kt | 8 +++---- .../specialCallsWithCallableReferences.fir.kt | 22 +++++++++---------- .../AssertNotNull.fir.kt | 2 +- .../TypeMismatchOnUnaryOperations.fir.kt | 2 +- .../tests/regressions/kt24488.fir.kt | 2 +- .../tests/resolve/newLineLambda.fir.kt | 2 +- .../diagnostics/tests/when/kt9929.fir.kt | 2 +- .../diagnostics/tests/when/kt9972.fir.kt | 8 +++---- .../when/whenAndLambdaWithExpectedType.fir.kt | 2 +- .../testsWithStdLib/tryCatch/assignTry.fir.kt | 2 +- .../try-expression/p-8/neg/1.1.fir.kt | 12 +++++----- .../diagnostics/notLinked/dfa/neg/1.fir.kt | 4 ++-- .../diagnostics/notLinked/dfa/pos/6.fir.kt | 4 ++-- 31 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.fir.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt index b8356fc3f04..7be0790c0e6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt @@ -5,8 +5,10 @@ package org.jetbrains.kotlin.fir.resolve.transformers +import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fakeElement import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder @@ -204,7 +206,7 @@ class FirSyntheticCallGenerator( ) } - return FirNamedReferenceWithCandidate(null, name, candidate) + return FirNamedReferenceWithCandidate(callSite.source?.fakeElement(KtFakeSourceElementKind.SyntheticCall), name, candidate) } private fun generateCandidate(callInfo: CallInfo, function: FirSimpleFunction, context: ResolutionContext): Candidate { diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt index f8c771dbae9..2a6ea8decac 100644 --- a/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt +++ b/compiler/frontend.common/src/org/jetbrains/kotlin/KtSourceElement.kt @@ -251,6 +251,9 @@ sealed class KtFakeSourceElementKind(final override val shouldSkipErrorTypeRepor // for return type of value parameters in lambdas object ImplicitReturnTypeOfLambdaValueParameter : KtFakeSourceElementKind() + + // Synthetic calls for if/when/try/etc. + object SyntheticCall : KtFakeSourceElementKind() } sealed class AbstractKtSourceElement { @@ -503,4 +506,3 @@ inline fun LighterASTNode.toKtLightSourceElement( startOffset: Int = this.startOffset, endOffset: Int = this.endOffset ): KtLightSourceElement = KtLightSourceElement(this, startOffset, endOffset, tree, kind) - diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt b/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt index 3dcdcf9b0cd..07e6140ef21 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.fir.kt @@ -4,8 +4,8 @@ fun test(s: IntRange?) { val a: Int = s?.start val b: Int? = s?.start val c: Int = s?.start ?: -11 - val d: Int = s?.start ?: "empty" - val e: String = s?.start ?: "empty" + val d: Int = s?.start ?: "empty" + val e: String = s?.start ?: "empty" val f: Int = s?.endInclusive ?: b ?: 1 val g: Boolean? = e.startsWith("s")//?.length } diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.fir.kt b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.fir.kt new file mode 100644 index 00000000000..f03e99d0c38 --- /dev/null +++ b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.fir.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +fun takeArray(array: Array) {} + +fun test() { + "foo bar".split([""]) + unresolved([""]) + takeArray([""]) + val v = [""] + [""] + [1, 2, 3].size +} + +fun baz(arg: Array = []) { + if (true) ["yes"] else {["no"]} +} + +class Foo( + val v: Array = [] +) diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.kt b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.kt index c3a917e9597..8b33d4e8264 100644 --- a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.kt +++ b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsOutsideOfAnnotations.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER fun takeArray(array: Array) {} diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt index 9c87721a8eb..d7e31c0b25d 100644 --- a/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt +++ b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt @@ -1,3 +1,3 @@ fun main() { - []!!!! -} \ No newline at end of file + []!!!! +} diff --git a/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt index 80a2c9c035c..cc477738e96 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/specialConstructsAndPlatformTypes.fir.kt @@ -29,7 +29,7 @@ val testSafeCall4: String? = J.m[""]?.let { it.toString() } val testIf1: String = if (true) J.s else J.s val testIf2: String? = if (true) J.s else J.s -val testIf3: String = if (true) J.m[""] else J.m[""] +val testIf3: String = if (true) J.m[""] else J.m[""] val testIf4: String? = if (true) J.m[""] else J.m[""] val testWhen1: String = when { else -> J.s } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt index 313c50c5a8b..a07e5bad292 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt @@ -1,6 +1,6 @@ fun test1() { - if (rr) { + if (rr) { if (l) { a.q() } @@ -15,7 +15,7 @@ fun test1() { else { a.u() } - } + } } fun test2(l: List<AA>) { diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt index ec9657bb98a..76ce3d37c81 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt @@ -136,7 +136,7 @@ fun poll16(flag: Boolean): Flow { fun poll17(flag: Boolean): Flow { return flow { - val inv = if (flag) { foo7() } else { ::Foo7 } + val inv = if (flag) { foo7() } else { ::Foo7 } inv } } @@ -185,7 +185,7 @@ fun poll25(flag: Boolean): Flow { fun poll26(flag: Boolean): Flow { return flow { - val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } + val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } inv } } @@ -234,7 +234,7 @@ fun poll35(flag: Boolean): Flow { fun poll36(flag: Boolean): Flow { return flow { - val inv = when (flag) { true -> ::Foo7 false -> foo7() } + val inv = when (flag) { true -> ::Foo7 false -> foo7() } inv } } @@ -332,7 +332,7 @@ fun poll55(): Flow { fun poll56(): Flow { return flow { - val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } + val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } inv } } @@ -430,7 +430,7 @@ fun poll75(): Flow { fun poll76(): Flow { return flow { - val inv = ::Foo7!! + val inv = ::Foo7!! inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt index 8a7000fc751..d9819355b91 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt @@ -85,7 +85,7 @@ fun poll16(flag: Boolean): Flow { fun poll17(flag: Boolean): Flow { return flow { - val inv = if (flag) { foo7() } else { ::Foo7 } + val inv = if (flag) { foo7() } else { ::Foo7 } inv } } @@ -183,7 +183,7 @@ fun poll55(): Flow { fun poll56(): Flow { return flow { - val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } + val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.fir.kt index da79c374535..f55b0663f40 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.fir.kt @@ -79,7 +79,7 @@ fun poll75(): Flow { fun poll76(): Flow { return flow { - val inv = ::Foo7!! + val inv = ::Foo7!! inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorTypeUnrestricted.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorTypeUnrestricted.fir.kt index a4d7d23fdce..b44791c73f7 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorTypeUnrestricted.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorTypeUnrestricted.fir.kt @@ -80,7 +80,7 @@ fun poll75(): Flow { fun poll76(): Flow { return flow { - val inv = ::Foo7!! + val inv = ::Foo7!! inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt index d231208f314..0e667264a73 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt @@ -138,7 +138,7 @@ fun poll16(flag: Boolean): Flow { fun poll17(flag: Boolean): Flow { return flow { - val inv = if (flag) { foo7() } else { ::Foo7 } + val inv = if (flag) { foo7() } else { ::Foo7 } inv } } @@ -187,7 +187,7 @@ fun poll25(flag: Boolean): Flow { fun poll26(flag: Boolean): Flow { return flow { - val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } + val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } inv } } @@ -236,7 +236,7 @@ fun poll35(flag: Boolean): Flow { fun poll36(flag: Boolean): Flow { return flow { - val inv = when (flag) { true -> ::Foo7 false -> foo7() } + val inv = when (flag) { true -> ::Foo7 false -> foo7() } inv } } @@ -334,7 +334,7 @@ fun poll55(): Flow { fun poll56(): Flow { return flow { - val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } + val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } inv } } @@ -432,7 +432,7 @@ fun poll75(): Flow { fun poll76(): Flow { return flow { - val inv = ::Foo7!! + val inv = ::Foo7!! inv } } diff --git a/compiler/testData/diagnostics/tests/inference/extensionLambdasAndArrow.fir.kt b/compiler/testData/diagnostics/tests/inference/extensionLambdasAndArrow.fir.kt index 390d99e0ca9..52b6b6cd38b 100644 --- a/compiler/testData/diagnostics/tests/inference/extensionLambdasAndArrow.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/extensionLambdasAndArrow.fir.kt @@ -8,9 +8,9 @@ fun main() { val x3: () -> String = if (true) {{ -> "this" }} else {{ -> "this" }} val x4: String.() -> String = if (true) {{ str: String -> "this" }} else {{ str: String -> "this" }} val x41: String.(String) -> String = if (true) {{ str: String, str2: String -> "this" }} else {{ str: String, str2: String -> "this" }} - val x42: String.(String) -> String = if (true) {{ str, str2 -> "this" }} else {{ str, str2 -> "this" }} - val x5: String.() -> String = if (true) {{ str -> "this" }} else {{ str -> "this" }} - val x6: String.() -> String = if (true) {{ str -> "this" }} else {{ "this" }} + val x42: String.(String) -> String = if (true) {{ str, str2 -> "this" }} else {{ str, str2 -> "this" }} + val x5: String.() -> String = if (true) {{ str -> "this" }} else {{ str -> "this" }} + val x6: String.() -> String = if (true) {{ str -> "this" }} else {{ "this" }} val x7: String.() -> String = select({ -> this }, { -> this }) val x8: String.() -> String = select({ this }, { this }) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt33629.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt33629.fir.kt index 9eeda35ce50..1be4ad4d550 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt33629.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt33629.fir.kt @@ -15,6 +15,6 @@ fun buildTree(segments: List): IntervalTree? = TODO() fun acquireIntervals(): List = TODO() fun main() { - buildTree(acquireIntervals()) - ?: emptyList() + buildTree(acquireIntervals()) + ?: emptyList() } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt35943.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt35943.fir.kt index 50339c0043a..f404e020740 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt35943.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt35943.fir.kt @@ -4,5 +4,5 @@ class Inv fun create(): Inv = TODO() fun main() { - if (true) create() else null + if (true) create() else null } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt36342.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt36342.fir.kt index 9d7cf27c4e6..873ab9f02d9 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt36342.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt36342.fir.kt @@ -4,21 +4,21 @@ import java.lang.Exception fun id(arg: K): K = arg fun test() { - id(unresolved)!! - unresolved!!!! - try { + id(unresolved)!! + unresolved!!!! + try { id(unresolved) } catch (e: Exception) { id(unresolved) - } + } - if (true) + if (true) id(unresolved) else - id(unresolved) + id(unresolved) when { true -> id(unresolved) } - id(unresolved) ?: id(unresolved) + id(unresolved) ?: id(unresolved) } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt index c264ff4bf26..9f2f92227a3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt948.fir.kt @@ -12,7 +12,7 @@ fun emptyList() : List? = ArrayList() fun foo() { // type arguments shouldn't be required val l : List = emptyList()!! - val l1 = emptyList()!! + val l1 = emptyList()!! checkSubtype>(emptyList()!!) checkSubtype?>(emptyList()) diff --git a/compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.fir.kt b/compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.fir.kt index c448776b18f..2eebfb6f659 100644 --- a/compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.fir.kt @@ -9,21 +9,21 @@ class Foo7 fun foo7() = null as Foo7 fun poll17(flag: Boolean): Any? { - val inv = if (flag) { foo7() } else { ::Foo7 } + val inv = if (flag) { foo7() } else { ::Foo7 } return inv } fun poll26(flag: Boolean): Any? { - val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } + val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } return inv } fun poll36(flag: Boolean): Any? { - val inv = when (flag) { true -> ::Foo7 false -> foo7() } + val inv = when (flag) { true -> ::Foo7 false -> foo7() } return inv } fun poll56(): Any? { - val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } + val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } return inv } diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index 8061d01ede8..b3590fc1912 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -44,7 +44,7 @@ fun poll13(flag: Boolean) { } fun poll14(flag: Boolean) { - val inv = if (flag) { ::bar4 } else { ::foo4 } + val inv = if (flag) { ::bar4 } else { ::foo4 } inv() } @@ -59,7 +59,7 @@ fun poll16(flag: Boolean) { } fun poll17(flag: Boolean) { - val inv = if (flag) { foo7() } else { ::Foo7 } + val inv = if (flag) { foo7() } else { ::Foo7 } inv } @@ -79,7 +79,7 @@ fun poll22(flag: Boolean) { } fun poll23(flag: Boolean) { - val inv = when (flag) { true -> ::bar4 else -> ::foo4 } + val inv = when (flag) { true -> ::bar4 else -> ::foo4 } inv() } @@ -94,7 +94,7 @@ fun poll25(flag: Boolean) { } fun poll26(flag: Boolean) { - val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } + val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 } inv } @@ -114,7 +114,7 @@ fun poll32(flag: Boolean) { } fun poll33(flag: Boolean) { - val inv = when (flag) { true -> ::bar4 false -> ::foo4 } + val inv = when (flag) { true -> ::bar4 false -> ::foo4 } inv() } @@ -129,7 +129,7 @@ fun poll35(flag: Boolean) { } fun poll36(flag: Boolean) { - val inv = when (flag) { true -> ::Foo7 false -> foo7() } + val inv = when (flag) { true -> ::Foo7 false -> foo7() } inv } @@ -149,7 +149,7 @@ fun poll42() { } fun poll43() { - val inv = try { ::bar4 } finally { ::foo4 } + val inv = try { ::bar4 } finally { ::foo4 } inv() } @@ -184,7 +184,7 @@ fun poll52() { } fun poll53() { - val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } + val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } inv() } @@ -199,7 +199,7 @@ fun poll55() { } fun poll56() { - val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } + val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() } inv } @@ -254,7 +254,7 @@ fun poll72() { } fun poll73() { - val inv = ::bar4!! + val inv = ::bar4!! inv } @@ -269,7 +269,7 @@ fun poll75() { } fun poll76() { - val inv = ::Foo7!! + val inv = ::Foo7!! inv } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt index 802373b198f..8a7e137060e 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/AssertNotNull.fir.kt @@ -33,6 +33,6 @@ fun main() { } } - val f : String = a!! + val f : String = a!! checkSubtype(a!!) } diff --git a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt index 748fda1aeeb..19cf94f6a89 100644 --- a/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/TypeMismatchOnUnaryOperations.fir.kt @@ -2,7 +2,7 @@ fun main() { val a : Int? = null; var v = 1 val b : String = v; - val f : String = a!!; + val f : String = a!!; val g : String = v++; val g1 : String = ++v; val h : String = v--; diff --git a/compiler/testData/diagnostics/tests/regressions/kt24488.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt24488.fir.kt index 0d7c8420d68..8d447dedcc0 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt24488.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt24488.fir.kt @@ -4,7 +4,7 @@ class Bar { val a: Array? = null } -fun foo(bar: Bar) = bar.a?.asIterable() ?: emptyArray() +fun foo(bar: Bar) = bar.a?.asIterable() ?: emptyArray() fun Array.asIterable(): Iterable = TODO() diff --git a/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt b/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt index 52f476530fe..3d1c12b15b4 100644 --- a/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/newLineLambda.fir.kt @@ -104,7 +104,7 @@ fun testTwoLambdas() { {} {} } else { - {} + {} } } } diff --git a/compiler/testData/diagnostics/tests/when/kt9929.fir.kt b/compiler/testData/diagnostics/tests/when/kt9929.fir.kt index 5a70d7b868b..e88d4f36ec5 100644 --- a/compiler/testData/diagnostics/tests/when/kt9929.fir.kt +++ b/compiler/testData/diagnostics/tests/when/kt9929.fir.kt @@ -1,4 +1,4 @@ -val test: Int = if (true) { +val test: Int = if (true) { when (2) { 1 -> 1 else -> null diff --git a/compiler/testData/diagnostics/tests/when/kt9972.fir.kt b/compiler/testData/diagnostics/tests/when/kt9972.fir.kt index 12843090fd3..defc2e4fe83 100644 --- a/compiler/testData/diagnostics/tests/when/kt9972.fir.kt +++ b/compiler/testData/diagnostics/tests/when/kt9972.fir.kt @@ -10,19 +10,19 @@ */ fun test1(): Int { - val x: String = if (true) { + val x: String = if (true) { when { true -> Any() else -> null } - } else "" + } else "" return x.hashCode() } fun test2(): Int { - val x: String = when { + val x: String = when { true -> Any() else -> null - } ?: return 0 + } ?: return 0 return x.hashCode() } diff --git a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.fir.kt b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.fir.kt index cdc33d4cf7f..939e379cccf 100644 --- a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.fir.kt @@ -29,7 +29,7 @@ val test3: (String) -> Boolean = val test4: (String) -> Boolean = when { - true -> { s1, s2 -> true } + true -> { s1, s2 -> true } else -> null!! } diff --git a/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt index 2f3683bacfe..a04b918628c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.fir.kt @@ -5,7 +5,7 @@ class ExcA : Exception() class ExcB : Exception() fun test2() { - val s: String? = try { + val s: String? = try { "" } catch (e: ExcA) { diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.fir.kt index 1a768ef5728..2d2fde14181 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.fir.kt @@ -13,12 +13,12 @@ class B(data: T) : A(data) fun case1() { val tryVal: B = - try { + try { throwExceptionA(false) A("") } catch (e: Exception) { B("") - } + } } @@ -27,12 +27,12 @@ fun case1() { fun case2() { val tryVal: A = - try { + try { throwExceptionA(false) A("") } catch (e: Exception) { null - } + } } /* @@ -42,14 +42,14 @@ fun case2() { */ fun case3() { val tryVal: A = - try { + try { throwExceptionA(false) A(2) } catch (e: ExcA) { A(null) //diag duplication } catch (e: ExcB) { B(null) //diag duplication - } + } } class ExcA() : Exception() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index 61c5a79ca48..e230f4012f6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -262,10 +262,10 @@ fun case_16() { } // TESTCASE NUMBER: 17 -val case_17 = if (nullableIntProperty == null == true == false) 0 else { +val case_17 = if (nullableIntProperty == null == true == false) 0 else { nullableIntProperty nullableIntProperty.java -} +} //TESTCASE NUMBER: 18 fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?) { 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 abb86aa7a81..59f74a654d4 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 @@ -732,11 +732,11 @@ fun case_37(x: Nothing?, y: Nothing?) { fun case_38() { val z = null - if (Object.prop_2 != z) + if (Object.prop_2 != z) else { Object.prop_2 Object.prop_2.java - } + } } // TESTCASE NUMBER: 39