From 528e538b2a1d14486612b8fcc59ef2f031280af1 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 1 Nov 2019 11:26:12 +0300 Subject: [PATCH] [FIR] Remove duplicating diagnostics from error function calls --- .../kotlin/fir/resolve/ResolveUtils.kt | 3 +- .../ErrorNodeDiagnosticCollectorComponent.kt | 2 ++ .../testData/resolve/arguments/default.kt | 8 ++--- .../testData/resolve/arguments/lambda.kt | 14 ++++---- .../testData/resolve/arguments/simple.kt | 14 ++++---- .../testData/resolve/arguments/vararg.kt | 8 ++--- .../resolve/testData/resolve/cfg/complex.kt | 12 +++---- .../fir/resolve/testData/resolve/cfg/jumps.kt | 2 +- .../testData/resolve/expresssions/access.kt | 8 ++--- .../testData/resolve/expresssions/access.txt | 4 +-- .../resolve/expresssions/companion.kt | 2 +- .../resolve/expresssions/companion.txt | 2 +- .../expresssions/inference/typeParameters.kt | 2 +- .../expresssions/inference/typeParameters.txt | 2 +- .../expresssions/inference/typeParameters2.kt | 2 +- .../inference/typeParameters2.txt | 2 +- .../expresssions/invoke/threeReceivers.kt | 2 +- .../expresssions/lambdaWithReceiver.kt | 4 +-- .../resolve/expresssions/localScopes.kt | 4 +-- .../expresssions/operators/plusAssign.kt | 2 +- .../expresssions/receiverConsistency.kt | 4 +-- .../testData/resolve/fromBuilder/enums.kt | 6 ++-- .../resolve/testData/resolve/functionTypes.kt | 2 +- .../resolve/testData/resolve/nested/inner.kt | 6 ++-- .../resolve/testData/resolve/nested/inner.txt | 2 +- .../resolve/testData/resolve/nested/simple.kt | 4 +-- .../testData/resolve/overrides/simple.kt | 2 +- .../resolve/smartcasts/booleanOperators.kt | 12 +++---- .../resolve/smartcasts/boundSmartcasts.kt | 4 +-- .../testData/resolve/smartcasts/casts.kt | 16 ++++----- .../resolve/smartcasts/endlessLoops.kt | 2 +- .../resolve/smartcasts/equalsAndIdentity.kt | 8 ++--- .../resolve/smartcasts/equalsToBoolean.kt | 16 ++++----- .../resolve/smartcasts/implicitReceivers.kt | 16 ++++----- .../resolve/smartcasts/nullability.kt | 36 +++++++++---------- .../testData/resolve/smartcasts/returns.kt | 12 +++---- .../testData/resolve/smartcasts/simpleIf.kt | 4 +-- .../stdlib/contracts/conditionalEffects.kt | 4 +-- .../testData/resolve/stdlib/problems.kt | 2 +- .../resolve/stdlib/simpleDelegatedToMap.txt | 12 +++---- .../resolve/typeAliasWithTypeArguments.kt | 2 +- .../testData/resolve/whenAsReceiver.kt | 2 +- .../kotlin/fir/diagnostics/FirDiagnostic.kt | 4 +++ 43 files changed, 142 insertions(+), 135 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 15893f74ff8..eb321e5d6dd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.componentArrayAccessor import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind +import org.jetbrains.kotlin.fir.diagnostics.FirEmptyDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.expressions.FirResolvable @@ -297,7 +298,7 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso return when (val newCallee = access.calleeReference) { is FirErrorNamedReference -> - FirErrorTypeRefImpl(access.source, newCallee.diagnostic) + FirErrorTypeRefImpl(access.source, FirEmptyDiagnostic) is FirNamedReferenceWithCandidate -> { typeFromSymbol(newCallee.candidateSymbol, makeNullable) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index 51e3747923f..4adcde617e2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirErrorFunction import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.FirEmptyDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirErrorExpression import org.jetbrains.kotlin.fir.expressions.FirErrorLoop @@ -56,6 +57,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect is FirAmbiguityError -> FirErrors.AMBIGUITY.onSource(source, diagnostic.candidates) is FirOperatorAmbiguityError -> FirErrors.ASSIGN_OPERATOR_AMBIGUITY.onSource(source, diagnostic.candidates) is FirSimpleDiagnostic -> diagnostic.getFactory().onSource(source) + FirEmptyDiagnostic -> null else -> throw IllegalArgumentException("Unsupported diagnostic type: ${diagnostic.javaClass}") } reporter.report(coneDiagnostic) diff --git a/compiler/fir/resolve/testData/resolve/arguments/default.kt b/compiler/fir/resolve/testData/resolve/arguments/default.kt index 933b0b52f39..bf5a1904af2 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/default.kt +++ b/compiler/fir/resolve/testData/resolve/arguments/default.kt @@ -8,19 +8,19 @@ fun test() { foo(1, 2.0, true) foo(1, third = true) - foo() - foo(0, 0.0, false, "") + foo() + foo(0, 0.0, false, "") bar(1, third = true) bar(1, 2.0, true) bar(1, 2.0, true, "my") - bar(1, true) + bar(1, true) baz(1) baz(1, "my", "yours") baz(1, z = true) - baz(0, "", false) + baz(0, "", false) } diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambda.kt b/compiler/fir/resolve/testData/resolve/arguments/lambda.kt index 0c2c596a69f..533f0f63e27 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/lambda.kt +++ b/compiler/fir/resolve/testData/resolve/arguments/lambda.kt @@ -8,21 +8,21 @@ fun test() { foo() {} foo({}) - foo(1) {} - foo(f = {}) {} + foo(1) {} + foo(f = {}) {} bar(1) {} bar(x = 1) {} bar(1, {}) bar(x = 1, f = {}) - bar {} - bar({}) + bar {} + bar({}) baz(other = false, f = {}) baz({}, false) - baz {} - baz() {} - baz(other = false) {} + baz {} + baz() {} + baz(other = false) {} } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arguments/simple.kt b/compiler/fir/resolve/testData/resolve/arguments/simple.kt index 7967530d7d9..45f51e84fc2 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/simple.kt +++ b/compiler/fir/resolve/testData/resolve/arguments/simple.kt @@ -7,11 +7,11 @@ fun test() { foo(1, second = 3.14, third = false, fourth = "!?") foo(third = false, second = 2.71, fourth = "?!", first = 0) - foo() - foo(0.0, false, 0, "") - foo(1, 2.0, third = true, "") - foo(second = 0.0, first = 0, fourth = "") - foo(first = 0.0, second = 0, third = "", fourth = false) - foo(first = 0, second = 0.0, third = false, fourth = "", first = 1) - foo(0, 0.0, false, foth = "") + foo() + foo(0.0, false, 0, "") + foo(1, 2.0, third = true, "") + foo(second = 0.0, first = 0, fourth = "") + foo(first = 0.0, second = 0, third = "", fourth = false) + foo(first = 0, second = 0.0, third = false, fourth = "", first = 1) + foo(0, 0.0, false, foth = "") } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arguments/vararg.kt b/compiler/fir/resolve/testData/resolve/arguments/vararg.kt index 68bdafea581..f42aee5067d 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/vararg.kt +++ b/compiler/fir/resolve/testData/resolve/arguments/vararg.kt @@ -7,11 +7,11 @@ fun test() { foo(1, "my", "yours") foo(1, *arrayOf("my", "yours")) - foo("") - foo(1, 2) + foo("") + foo(1, 2) bar(1, z = true, y = *arrayOf("my", "yours")) - bar(0, z = false, y = "", y = "other") - bar(0, "", true) + bar(0, z = false, y = "", y = "other") + bar(0, "", true) } diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.kt b/compiler/fir/resolve/testData/resolve/cfg/complex.kt index 49f02f2ea5c..ba27b36f120 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.kt @@ -1,15 +1,15 @@ -@Throws(IOException::class, ResponseParseException::class) +@Throws(IOException::class, ResponseParseException::class) fun fetchPluginReleaseDate(pluginId: PluginId, version: String, channel: String?): LocalDate? { - val url = "https://plugins.jetbrains.com/api/plugins/${pluginId.idString}/updates?version=$version" + val url = "https://plugins.jetbrains.com/api/plugins/${pluginId.idString}/updates?version=$version" val pluginDTOs: Array = try { - HttpRequests.request(url).connect { + HttpRequests.request(url).connect { GsonBuilder().create().fromJson(it.inputStream.reader(), Array::class.java) - } + } } catch (ioException: JsonIOException) { - throw IOException(ioException) + throw IOException(ioException) } catch (syntaxException: JsonSyntaxException) { - throw ResponseParseException("Can't parse json response", syntaxException) + throw ResponseParseException("Can't parse json response", syntaxException) } } diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt index 3ac7aa9d9ed..eb6f69999cd 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt @@ -13,7 +13,7 @@ fun test_2(x: Int?) { } else { x } - y.inc() + y.inc() } fun test_3(x: Int?) { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/access.kt b/compiler/fir/resolve/testData/resolve/expresssions/access.kt index 2a8b03e6313..21932a5d597 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/access.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/access.kt @@ -21,7 +21,7 @@ class Bar { } // NB! abc() here is resolved to member Foo.abc(), and not to extension member of Bar - fun Foo.check() = abc() + bar() + fun Foo.check() = abc() + bar() // NB! + here is resolved to member String.plus (not to extension member above) fun Foo.check2() = "" + bar() @@ -41,9 +41,9 @@ fun f() { val a = 10 val b = a val d = "" - val c = c + val c = c - abc() + abc() fun bcd() {} @@ -57,7 +57,7 @@ fun f() { dcb() } - dcb() + dcb() abc() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/access.txt b/compiler/fir/resolve/testData/resolve/expresssions/access.txt index 48f29ca4a2f..1c08ad9db18 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/access.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/access.txt @@ -36,7 +36,7 @@ FILE: access.kt ^plus String() } - public final fun R|Foo|.check(): { + public final fun R|Foo|.check(): { ^check this@R|/Foo|.R|/Foo.abc|().#(this@R|/Bar|.R|/Bar.bar|()) } @@ -57,7 +57,7 @@ FILE: access.kt lval a: R|kotlin/Int| = Int(10) lval b: R|kotlin/Int| = R|/a| lval d: R|kotlin/String| = String() - lval c: = # + lval c: = # #() local final fun bcd(): R|kotlin/Unit| { } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/companion.kt b/compiler/fir/resolve/testData/resolve/expresssions/companion.kt index 74431e75404..8bc9fa378a3 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/companion.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/companion.kt @@ -22,5 +22,5 @@ fun test() { B.baz() val x = A.D val y = B.C - val z = B.D + val z = B.D } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt index 27b77514e9a..7ce4e7b1d99 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt @@ -47,5 +47,5 @@ FILE: companion.kt Q|B|.R|/B.Companion.baz|() lval x: R|kotlin/String| = Q|A|.R|/A.Companion.D| lval y: R|kotlin/String| = Q|B|.R|/B.Companion.C| - lval z: = Q|B|.# + lval z: = Q|B|.# } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.kt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.kt index 9f11c3fe884..e73ddbe3285 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.kt @@ -7,5 +7,5 @@ fun foo(t: T) = t fun main(fooImpl: FooImpl, bar: Bar) { val a = foo(fooImpl) - val b = foo(bar) + val b = foo(bar) } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.txt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.txt index aeec9b3958a..265ce45cef9 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.txt @@ -18,5 +18,5 @@ FILE: typeParameters.kt } public final fun main(fooImpl: R|FooImpl|, bar: R|Bar|): R|kotlin/Unit| { lval a: R|FooImpl| = R|/foo|(R|/fooImpl|) - lval b: = #(R|/bar|) + lval b: = #(R|/bar|) } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.kt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.kt index 8e155e73b7b..931964e572c 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.kt @@ -6,6 +6,6 @@ fun foo(t: T) = t fun main(fooImpl: FooImpl, fooBarImpl: FooBarImpl) { - val a = foo(fooBarImpl) + val a = foo(fooBarImpl) val b = foo(fooImpl) } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.txt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.txt index db7289b97f7..8fa926187ed 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.txt @@ -17,6 +17,6 @@ FILE: typeParameters2.kt ^foo R|/t| } public final fun main(fooImpl: R|FooImpl|, fooBarImpl: R|FooBarImpl|): R|kotlin/Unit| { - lval a: = #(R|/fooBarImpl|) + lval a: = #(R|/fooBarImpl|) lval b: R|Foo| = R|/foo|(R|/fooImpl|) } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt index f4c2db1e540..8c3918b5a7f 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/invoke/threeReceivers.kt @@ -12,6 +12,6 @@ class Foo { val Buz.foobar: Bar get() = Bar() fun FooBar.chk(buz: Buz) { - buz.foobar() + buz.foobar() } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt index ad5b56a6811..604b2f69eda 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambdaWithReceiver.kt @@ -3,11 +3,11 @@ interface A { } fun myWith(receiver: T, block: T.() -> Unit) { - receiver.block() + receiver.block() } fun T.myApply(block: T.() -> Unit) { - this.block() + this.block() } fun withA(block: A.() -> Unit) {} diff --git a/compiler/fir/resolve/testData/resolve/expresssions/localScopes.kt b/compiler/fir/resolve/testData/resolve/expresssions/localScopes.kt index 69ce60b3adf..ef42af97743 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/localScopes.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/localScopes.kt @@ -23,6 +23,6 @@ fun test() { val derived = DerivedLocal() derived.gau() - derived.baz() - derived.foo() + derived.baz() + derived.foo() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/operators/plusAssign.kt b/compiler/fir/resolve/testData/resolve/expresssions/operators/plusAssign.kt index 9d519b6f571..b2084548df9 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/operators/plusAssign.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/operators/plusAssign.kt @@ -7,7 +7,7 @@ class Foo { fun test_1() { val f = Foo() - f + f + f + f } fun test_2() { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/receiverConsistency.kt b/compiler/fir/resolve/testData/resolve/expresssions/receiverConsistency.kt index f7e43a90d67..714ba2fcbc1 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/receiverConsistency.kt +++ b/compiler/fir/resolve/testData/resolve/expresssions/receiverConsistency.kt @@ -6,7 +6,7 @@ class C { class Nested { fun test() { - err() + err() } } } @@ -17,5 +17,5 @@ fun test() { c.bar() val err = C() - err.foo() + err.foo() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.kt b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.kt index 5254289c608..627ab90dfe2 100644 --- a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.kt +++ b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.kt @@ -9,17 +9,17 @@ enum class Order { enum class Planet(val m: Double, internal val r: Double) { MERCURY(1.0, 2.0) { override fun sayHello() { - println("Hello!!!") + println("Hello!!!") } }, VENERA(3.0, 4.0) { override fun sayHello() { - println("Ola!!!") + println("Ola!!!") } }, EARTH(5.0, 6.0) { override fun sayHello() { - println("Privet!!!") + println("Privet!!!") } }; diff --git a/compiler/fir/resolve/testData/resolve/functionTypes.kt b/compiler/fir/resolve/testData/resolve/functionTypes.kt index b9762085001..ce21d01bd71 100644 --- a/compiler/fir/resolve/testData/resolve/functionTypes.kt +++ b/compiler/fir/resolve/testData/resolve/functionTypes.kt @@ -4,7 +4,7 @@ fun List.simpleMap(f: (T) -> R): R { } -fun simpleWith(t: T, f: T.() -> Unit): Unit = t.f() +fun simpleWith(t: T, f: T.() -> Unit): Unit = t.f() interface KMutableProperty1 : KProperty1, KMutableProperty diff --git a/compiler/fir/resolve/testData/resolve/nested/inner.kt b/compiler/fir/resolve/testData/resolve/nested/inner.kt index 552246a1eb8..8e1ca1419a8 100644 --- a/compiler/fir/resolve/testData/resolve/nested/inner.kt +++ b/compiler/fir/resolve/testData/resolve/nested/inner.kt @@ -23,7 +23,7 @@ class Owner { o.foo() foo() this@Owner.foo() - this.err() + this.err() } } } @@ -31,8 +31,8 @@ class Owner { fun test() { val o = Owner() o.foo() - val err = Owner.Inner() - err.baz() + val err = Owner.Inner() + err.baz() val i = o.Inner() i.gau() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/nested/inner.txt b/compiler/fir/resolve/testData/resolve/nested/inner.txt index d4e4e9db0d8..5cd8290112c 100644 --- a/compiler/fir/resolve/testData/resolve/nested/inner.txt +++ b/compiler/fir/resolve/testData/resolve/nested/inner.txt @@ -41,7 +41,7 @@ FILE: inner.kt public final fun test(): R|kotlin/Unit| { lval o: R|Owner| = R|/Owner.Owner|() R|/o|.R|/Owner.foo|() - lval err: = Q|Owner|.#() + lval err: = Q|Owner|.#() R|/err|.#() lval i: R|Owner.Inner| = R|/o|.R|/Owner.Inner.Inner|() R|/i|.R|/Owner.Inner.gau|() diff --git a/compiler/fir/resolve/testData/resolve/nested/simple.kt b/compiler/fir/resolve/testData/resolve/nested/simple.kt index fa13698ff65..a42556effec 100644 --- a/compiler/fir/resolve/testData/resolve/nested/simple.kt +++ b/compiler/fir/resolve/testData/resolve/nested/simple.kt @@ -22,8 +22,8 @@ class Owner { } fun err() { - foo() - this.foo() + foo() + this.foo() } } } diff --git a/compiler/fir/resolve/testData/resolve/overrides/simple.kt b/compiler/fir/resolve/testData/resolve/overrides/simple.kt index cc34d3d2e91..56fd4e8522a 100644 --- a/compiler/fir/resolve/testData/resolve/overrides/simple.kt +++ b/compiler/fir/resolve/testData/resolve/overrides/simple.kt @@ -14,7 +14,7 @@ class B : A() { fun test() { foo() bar() - buz() + buz() } } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.kt b/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.kt index c0e129b999e..af00bb5ef9c 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/booleanOperators.kt @@ -23,8 +23,8 @@ fun test_1(x: Any) { fun test_2(x: Any) { if (x is B || x is C) { x.foo() - x.bar() - x.baz() + x.bar() + x.baz() } } @@ -36,20 +36,20 @@ fun test_3(x: Any) { fun test_4(x: Any) { if (x !is String || x.length == 0) { - x.length + x.length } - x.length + x.length } fun test_5(x: A?) { if (x != null || false) { - x.foo() + x.foo() } } fun test_6(x: A?) { if (false || x != null) { - x.foo() + x.foo() } } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts.kt b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts.kt index 51ec509eab4..accfa527131 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/boundSmartcasts.kt @@ -29,7 +29,7 @@ fun test_3(x: Any, y: Any) { } z = y if (y is B) { - z.bar() + z.bar() } } @@ -40,7 +40,7 @@ fun test_4(y: Any) { x = y x.inc() if (y is A) { - x.foo() + x.foo() y.foo() } } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt b/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt index f6060dd8605..7ccaebc0256 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/casts.kt @@ -14,31 +14,31 @@ fun test_3(b: Boolean, x: Any?) { if (b && x as Boolean) { x.not() } - x.not() + x.not() if (b && x as Boolean == true) { x.not() } - x.not() + x.not() if (b || x as Boolean) { - x.not() + x.not() } - x.not() + x.not() } fun test_4(b: Any) { if (b as? Boolean != null) { b.not() } else { - b.not() + b.not() } - b.not() + b.not() if (b as? Boolean == null) { - b.not() + b.not() } else { b.not() } - b.not() + b.not() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/endlessLoops.kt b/compiler/fir/resolve/testData/resolve/smartcasts/endlessLoops.kt index 0693f478231..83758a1d4ff 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/endlessLoops.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/endlessLoops.kt @@ -43,7 +43,7 @@ fun test_4(x: Any, b: Boolean) { } break } - x.foo() // No smartcast + x.foo() // No smartcast } fun test_5(x: Any, b: Boolean) { diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt b/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt index 63f6fa27d39..b0371ed8143 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/equalsAndIdentity.kt @@ -15,12 +15,12 @@ fun test_1(x: A, y: A?) { fun test_2(x: A?, y: A?) { if (x == y) { - x.foo() - y.foo() + x.foo() + y.foo() } if (x === y) { - x.foo() - y.foo() + x.foo() + y.foo() } } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/equalsToBoolean.kt b/compiler/fir/resolve/testData/resolve/smartcasts/equalsToBoolean.kt index f151b158d20..3ff1aa1fb7d 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/equalsToBoolean.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/equalsToBoolean.kt @@ -7,13 +7,13 @@ fun test_1(b: Boolean?) { if ((b == true) == true) { b.not() // OK } else { - b.not() // Bad + b.not() // Bad } } fun test_2(b: Boolean?) { if ((b == true) != true) { - b.not() // Bad + b.not() // Bad } else { b.not() // OK } @@ -21,7 +21,7 @@ fun test_2(b: Boolean?) { fun test_3(b: Boolean?) { if ((b == true) == false) { - b.not() // Bad + b.not() // Bad } else { b.not() // OK } @@ -31,13 +31,13 @@ fun test_4(b: Boolean?) { if ((b == true) != false) { b.not() // OK } else { - b.not() // Bad + b.not() // Bad } } fun test_5(b: Boolean?) { if ((b != true) == true) { - b.not() // Bad + b.not() // Bad } else { b.not() // OK } @@ -47,7 +47,7 @@ fun test_6(b: Boolean?) { if ((b != true) != true) { b.not() // OK } else { - b.not() // Bad + b.not() // Bad } } @@ -55,13 +55,13 @@ fun test_7(b: Boolean?) { if ((b != true) == false) { b.not() // OK } else { - b.not() // Bad + b.not() // Bad } } fun test_8(b: Boolean?) { if ((b != true) != false) { - b.not() // Bad + b.not() // Bad } else { b.not() // OK } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.kt b/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.kt index b813372e481..025bbe2725d 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/implicitReceivers.kt @@ -9,23 +9,23 @@ fun Any?.test_1() { this.foo() foo() } else { - this.foo() - foo() + this.foo() + foo() } - this.foo() - foo() + this.foo() + foo() } fun Any?.test_2() { if (this !is A) { - this.foo() - foo() + this.foo() + foo() } else { this.foo() foo() } - this.foo() - foo() + this.foo() + foo() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt index ace76949121..7b44f85e9bf 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/nullability.kt @@ -21,18 +21,18 @@ fun test_1(x: A?) { if (x != null) { x.foo() } else { - x.foo() + x.foo() } - x.foo() + x.foo() } fun test_2(x: A?) { if (x == null) { - x.foo() + x.foo() } else { x.foo() } - x.foo() + x.foo() } fun test_3(x: A?) { @@ -63,8 +63,8 @@ fun test_6(q: Q?) { fun test_7(q: Q?) { if (q?.fdata()?.fs()?.inc() != null) { q.fdata() // good - q.fdata().fs() // bad - q.fdata().fs().inc() // bad + q.fdata().fs() // bad + q.fdata().fs().inc() // bad } } @@ -78,42 +78,42 @@ fun test_9(a: Int, b: Int?) { if (a == b) { b.inc() } - b.inc() + b.inc() if (a === b) { b.inc() } - b.inc() + b.inc() if (b == a) { b.inc() } - b.inc() + b.inc() if (b === a) { b.inc() } - b.inc() + b.inc() } fun test_10(a: Int?, b: Int?) { if (a == b) { - b.inc() + b.inc() } - b.inc() + b.inc() if (a === b) { - b.inc() + b.inc() } - b.inc() + b.inc() if (b == a) { - b.inc() + b.inc() } - b.inc() + b.inc() if (b === a) { - b.inc() + b.inc() } - b.inc() + b.inc() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/returns.kt b/compiler/fir/resolve/testData/resolve/smartcasts/returns.kt index a926f998181..5a0d1ca390f 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/returns.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/returns.kt @@ -4,7 +4,7 @@ fun test_0(x: Any) { } else { } - x.length + x.length } fun test_1(x: Any) { @@ -35,8 +35,8 @@ fun test_2(x: Any) { else -> return } x.foo() - x.bar() - x.baz() + x.bar() + x.baz() } fun test_3(x: Any) { @@ -44,7 +44,7 @@ fun test_3(x: Any) { x is B -> x.bar() x is C -> x.baz() } - x.foo() - x.bar() - x.baz() + x.foo() + x.bar() + x.baz() } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/simpleIf.kt b/compiler/fir/resolve/testData/resolve/smartcasts/simpleIf.kt index c8490a36422..d2d2da7be00 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/simpleIf.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/simpleIf.kt @@ -2,7 +2,7 @@ fun test_1(x: Any) { if (x is String) { x.length } - x.length + x.length } fun test_2(x: Any) { @@ -10,7 +10,7 @@ fun test_2(x: Any) { if (b) { x.length } - x.length + x.length } fun test_3(x: Any) { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/contracts/conditionalEffects.kt b/compiler/fir/resolve/testData/resolve/stdlib/contracts/conditionalEffects.kt index fa6e57374d8..370dea091a8 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/contracts/conditionalEffects.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/contracts/conditionalEffects.kt @@ -24,9 +24,9 @@ fun test_5(x: Any, b: Boolean) { require(x is String) x.length } else { - x.length + x.length } - x.length + x.length } fun test_6(x: Any, b: Boolean) { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems.kt b/compiler/fir/resolve/testData/resolve/stdlib/problems.kt index f9fad433f52..8a6700abd73 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/problems.kt @@ -30,5 +30,5 @@ class BC : B, C fun C.analyze() {} inline fun T.analyze() where T : A, T : B {} fun testAnalyze() { - BC().analyze() + BC().analyze() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt index c4019f42bea..c01ec5107d5 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt @@ -7,19 +7,19 @@ FILE: simpleDelegatedToMap.kt public final val map: R|kotlin/collections/MutableMap| = R|/map| public get(): R|kotlin/collections/MutableMap| - public final var foo: by R|/map| - public get(): { + public final var foo: by R|/map| + public get(): { ^ D|/C.foo|.#(this@R|/C|, ::R|/C.foo|) } - public set(: ): R|kotlin/Unit| { + public set(: ): R|kotlin/Unit| { D|/C.foo|.#(this@R|/C|, ::R|/C.foo|, R|/foo|) } } - public final var bar: by R|kotlin/collections/hashMapOf|() - public get(): { + public final var bar: by R|kotlin/collections/hashMapOf|() + public get(): { ^ D|/bar|.#(Null(null), ::R|/bar|) } - public set(: ): R|kotlin/Unit| { + public set(: ): R|kotlin/Unit| { D|/bar|.#(Null(null), ::R|/bar|, R|/bar|) } diff --git a/compiler/fir/resolve/testData/resolve/typeAliasWithTypeArguments.kt b/compiler/fir/resolve/testData/resolve/typeAliasWithTypeArguments.kt index a9f364cdd67..436c229d332 100644 --- a/compiler/fir/resolve/testData/resolve/typeAliasWithTypeArguments.kt +++ b/compiler/fir/resolve/testData/resolve/typeAliasWithTypeArguments.kt @@ -42,7 +42,7 @@ fun test_2(inv: Inv2) { fun test_3(inv: Inv3) { inv.k().foo() - inv.t().bar() + inv.t().bar() inv.t().baz() } diff --git a/compiler/fir/resolve/testData/resolve/whenAsReceiver.kt b/compiler/fir/resolve/testData/resolve/whenAsReceiver.kt index 2706a6e1936..96199d335c3 100644 --- a/compiler/fir/resolve/testData/resolve/whenAsReceiver.kt +++ b/compiler/fir/resolve/testData/resolve/whenAsReceiver.kt @@ -1,5 +1,5 @@ fun T.also(block: () -> R): R { - return null!! + return null!! } fun foo(b: Boolean, a: Int) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/FirDiagnostic.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/FirDiagnostic.kt index 674c7153e24..2623606dc24 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/FirDiagnostic.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/FirDiagnostic.kt @@ -7,4 +7,8 @@ package org.jetbrains.kotlin.fir.diagnostics abstract class FirDiagnostic { abstract val reason: String +} + +object FirEmptyDiagnostic : FirDiagnostic() { + override val reason: String get() = "Empty diagnostic" } \ No newline at end of file