From 11063a25a86d647313fec755b5034e8dffe1cd93 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 14 Nov 2019 11:23:59 +0300 Subject: [PATCH] [FIR] Replace FirEmptyDiagnostic with FirStubDiagnostic FirStubDiagnostic hold reason from original diagnostic It's useful in HTML fir dump --- .../org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt | 4 ++-- .../ErrorNodeDiagnosticCollectorComponent.kt | 4 ++-- .../fir/resolve/testData/resolve/cfg/complex.dot | 2 +- .../fir/resolve/testData/resolve/cfg/complex.txt | 2 +- .../resolve/testData/resolve/expresssions/access.txt | 4 ++-- .../testData/resolve/expresssions/companion.txt | 2 +- .../expresssions/inference/typeParameters.txt | 2 +- .../expresssions/inference/typeParameters2.txt | 2 +- .../fir/resolve/testData/resolve/nested/inner.txt | 2 +- .../testData/resolve/nestedClassContructor.txt | 2 +- .../stdlib/callableReferences/implicitTypes.txt | 2 +- .../testData/resolve/stdlib/j+k/MyException.txt | 6 +++--- .../testData/resolve/stdlib/j+k/MyIterable.txt | 4 ++-- .../resolve/testData/resolve/stdlib/j+k/MyMap.txt | 4 ++-- .../testData/resolve/stdlib/reflectionClass.txt | 2 +- .../testData/resolve/stdlib/simpleDelegatedToMap.txt | 12 ++++++------ .../org/jetbrains/kotlin/fir/FirResolveBench.kt | 6 +++--- .../kotlin/fir/diagnostics/FirDiagnostic.kt | 4 ++-- 18 files changed, 33 insertions(+), 33 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 04b677ffc35..9e059a7781d 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,7 +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.FirStubDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression @@ -304,7 +304,7 @@ fun BodyResolveComponents.typeFromCallee(access: T): FirReso return when (val newCallee = access.calleeReference) { is FirErrorNamedReference -> - FirErrorTypeRefImpl(access.source, FirEmptyDiagnostic) + FirErrorTypeRefImpl(access.source, FirStubDiagnostic(newCallee.diagnostic)) 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 4b2db1e9cea..9471bb11ad6 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,7 +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.FirStubDiagnostic import org.jetbrains.kotlin.fir.diagnostics.FirSimpleDiagnostic import org.jetbrains.kotlin.fir.expressions.FirErrorExpression import org.jetbrains.kotlin.fir.expressions.FirErrorLoop @@ -58,7 +58,7 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect is FirOperatorAmbiguityError -> FirErrors.ASSIGN_OPERATOR_AMBIGUITY.onSource(source, diagnostic.candidates) is FirVariableExpectedError -> Errors.VARIABLE_EXPECTED.onSource(source) is FirSimpleDiagnostic -> diagnostic.getFactory().onSource(source) - FirEmptyDiagnostic -> null + is FirStubDiagnostic -> null else -> throw IllegalArgumentException("Unsupported diagnostic type: ${diagnostic.javaClass}") } reporter.report(coneDiagnostic) diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.dot b/compiler/fir/resolve/testData/resolve/cfg/complex.dot index e4ee21436c6..4f6dfabf1ad 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.dot @@ -28,7 +28,7 @@ digraph complex_kt { 12 [label="Access variable R|/url|"]; 13 [label="Access variable R|/url|"]; 14 [label="Function call: #.#(R|/url|)"]; - 15 [label="Function call: #.#(R|/url|).#( = connect@fun .(): { + 15 [label="Function call: #.#(R|/url|).#( = connect@fun .(): { #().#().#(#.#.#(), (#()).#) } )"]; diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.txt b/compiler/fir/resolve/testData/resolve/cfg/complex.txt index 2d7b512be1f..101bf4bfeb6 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.txt @@ -2,7 +2,7 @@ FILE: complex.kt @R|kotlin/jvm/Throws|((#), (#)) public final fun fetchPluginReleaseDate(pluginId: R|class error: Symbol not found, for `PluginId`|, version: R|kotlin/String|, channel: R|kotlin/String?|): R|class error: Symbol not found, for `LocalDate?`| { lval url: R|kotlin/String| = (String(https://plugins.jetbrains.com/api/plugins/), R|/pluginId|.#, String(/updates?version=), R|/version|) lval pluginDTOs: R|kotlin/Array| = try { - #.#(R|/url|).#( = connect@fun .(): { + #.#(R|/url|).#( = connect@fun .(): { #().#().#(#.#.#(), (#()).#) } ) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/access.txt b/compiler/fir/resolve/testData/resolve/expresssions/access.txt index 1c08ad9db18..48f29ca4a2f 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.txt b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt index 7ce4e7b1d99..27b77514e9a 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.txt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters.txt index 265ce45cef9..aeec9b3958a 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.txt b/compiler/fir/resolve/testData/resolve/expresssions/inference/typeParameters2.txt index 8fa926187ed..db7289b97f7 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/nested/inner.txt b/compiler/fir/resolve/testData/resolve/nested/inner.txt index 5cd8290112c..d4e4e9db0d8 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/nestedClassContructor.txt b/compiler/fir/resolve/testData/resolve/nestedClassContructor.txt index 0a630e1fcb4..beb8e3231b7 100644 --- a/compiler/fir/resolve/testData/resolve/nestedClassContructor.txt +++ b/compiler/fir/resolve/testData/resolve/nestedClassContructor.txt @@ -9,7 +9,7 @@ FILE: nestedClassContructor.kt super() } - public final fun copy(): { + public final fun copy(): { ^copy #() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt index 6b1a5cd05f0..8cfa49e1956 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/callableReferences/implicitTypes.txt @@ -8,7 +8,7 @@ FILE: implicitTypes.kt public final fun bar(x: R|kotlin/String|): R|kotlin/Int| { ^bar Int(1) } - public final fun loop1(): { + public final fun loop1(): { ^loop1 #(::R|/loop2|) } public final fun loop2(): { diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyException.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyException.txt index 3b0b82f75ea..dad4eeb6c3d 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyException.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyException.txt @@ -8,15 +8,15 @@ FILE: test.kt public final fun test(e: R|MyException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| { R|/e|.R|kotlin/printStackTrace|() R|/e|.R|kotlin/printStackTrace|(R|/stream|) - lval result: = R|/e|.#() + lval result: = R|/e|.#() } public final fun test(e: R|YourException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| { R|/e|.R|kotlin/printStackTrace|() R|/e|.R|kotlin/printStackTrace|(R|/stream|) - lval result: = R|/e|.#() + lval result: = R|/e|.#() } public final fun test(e: R|kotlin/Exception|, stream: R|java/io/PrintStream|): R|kotlin/Unit| { R|/e|.R|kotlin/printStackTrace|() R|/e|.R|kotlin/printStackTrace|(R|/stream|) - lval result: = R|/e|.#() + lval result: = R|/e|.#() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt index f39203c2115..b10f1123687 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt @@ -2,11 +2,11 @@ FILE: test.kt public abstract interface UseIterable : R|MyIterable| { public open fun test(): R|kotlin/Unit| { lval it: R|kotlin/collections/MutableIterator| = this@R|kotlin/collections/MutableIterable|.R|FakeOverride|>|() - lval split: = #() + lval split: = #() } } public final fun test(some: R|kotlin/collections/Iterable|): R|kotlin/Unit| { lval it: R|kotlin/collections/Iterator| = R|/some|.R|FakeOverride|>|() - lval split: = R|/some|.#() + lval split: = R|/some|.#() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt index 2bbf6ac6c4c..9d76304d675 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt @@ -5,7 +5,7 @@ FILE: test.kt } ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) - lval anotherResult: = R|/map|.#(String(key), String(value)) + lval anotherResult: = R|/map|.#(String(key), String(value)) R|/map|.#( = forEach@fun .(key: , value: ): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } @@ -23,7 +23,7 @@ FILE: test.kt } ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) - lval anotherResult: = R|/map|.#(String(key), String(value)) + lval anotherResult: = R|/map|.#(String(key), String(value)) R|/map|.#( = forEach@fun .(key: , value: ): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt b/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt index 9d0d040ebc6..d59b8e9dbfa 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt @@ -5,5 +5,5 @@ FILE: reflectionClass.kt public get(): R|kotlin/reflect/KClass| public final fun foo(): R|kotlin/Unit| { lval stringClass: R|java/lang/Class| = (Q|kotlin/String|).R|kotlin/jvm/java| - lval arrayStringClass: = (#()).# + lval arrayStringClass: = (#()).# } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt index c01ec5107d5..c4019f42bea 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/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt index dc2119f52a1..3f071f1afc7 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveBench.kt @@ -8,7 +8,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.builder.RawFirBuilder import org.jetbrains.kotlin.fir.declarations.FirFile -import org.jetbrains.kotlin.fir.diagnostics.FirEmptyDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.FirStubDiagnostic import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression import org.jetbrains.kotlin.fir.references.FirErrorNamedReference @@ -228,7 +228,7 @@ class FirResolveBench(val withProgress: Boolean) { unresolvedTypes++ if (typeRef.psi != null) { - if (typeRef is FirErrorTypeRef && typeRef.diagnostic == FirEmptyDiagnostic) { + if (typeRef is FirErrorTypeRef && typeRef.diagnostic is FirStubDiagnostic) { return } val psi = typeRef.psi!! @@ -253,7 +253,7 @@ class FirResolveBench(val withProgress: Boolean) { implicitTypes++ } else { errorTypes++ - if (resolvedTypeRef is FirErrorTypeRef && resolvedTypeRef.diagnostic == FirEmptyDiagnostic) { + if (resolvedTypeRef is FirErrorTypeRef && resolvedTypeRef.diagnostic is FirStubDiagnostic) { return } val psi = resolvedTypeRef.psi!! 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 2623606dc24..7219e9be4aa 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 @@ -9,6 +9,6 @@ abstract class FirDiagnostic { abstract val reason: String } -object FirEmptyDiagnostic : FirDiagnostic() { - override val reason: String get() = "Empty diagnostic" +class FirStubDiagnostic(val original: FirDiagnostic) : FirDiagnostic() { + override val reason: String get() = original.reason } \ No newline at end of file