[FIR] Replace FirEmptyDiagnostic with FirStubDiagnostic

FirStubDiagnostic hold reason from original diagnostic
It's useful in HTML fir dump
This commit is contained in:
Dmitriy Novozhilov
2019-11-14 11:23:59 +03:00
parent ee20f88837
commit 11063a25a8
18 changed files with 33 additions and 33 deletions
@@ -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 <T : FirResolvable> 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)
}
@@ -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)
+1 -1
View File
@@ -28,7 +28,7 @@ digraph complex_kt {
12 [label="Access variable R|<local>/url|"];
13 [label="Access variable R|<local>/url|"];
14 [label="Function call: <Unresolved name: HttpRequests>#.<Unresolved name: request>#(R|<local>/url|)"];
15 [label="Function call: <Unresolved name: HttpRequests>#.<Unresolved name: request>#(R|<local>/url|).<Unresolved name: connect>#(<L> = connect@fun <implicit>.<anonymous>(): <ERROR TYPE REF: Empty diagnostic> {
15 [label="Function call: <Unresolved name: HttpRequests>#.<Unresolved name: request>#(R|<local>/url|).<Unresolved name: connect>#(<L> = connect@fun <implicit>.<anonymous>(): <ERROR TYPE REF: Unresolved name: fromJson> {
<Unresolved name: GsonBuilder>#().<Unresolved name: create>#().<Unresolved name: fromJson>#(<Unresolved name: it>#.<Unresolved name: inputStream>#.<Ambiguity: reader, [kotlin/io/reader, kotlin/io/reader, kotlin/io/reader]>#(), <getClass>(<Inapplicable(PARAMETER_MAPPING_ERROR): [kotlin/Array.Array]>#<R|class error: Symbol not found, for `PluginDTO`|>()).<Inapplicable(WRONG_RECEIVER): [kotlin/jvm/java]>#)
}
)"];
+1 -1
View File
@@ -2,7 +2,7 @@ FILE: complex.kt
@R|kotlin/jvm/Throws|(<getClass>(<Unresolved name: IOException>#), <getClass>(<Unresolved name: ResponseParseException>#)) 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| = <strcat>(String(https://plugins.jetbrains.com/api/plugins/), R|<local>/pluginId|.<Unresolved name: idString>#, String(/updates?version=), R|<local>/version|)
lval pluginDTOs: R|kotlin/Array<class error: Symbol not found, for `PluginDTO`>| = try {
<Unresolved name: HttpRequests>#.<Unresolved name: request>#(R|<local>/url|).<Unresolved name: connect>#(<L> = connect@fun <implicit>.<anonymous>(): <ERROR TYPE REF: Empty diagnostic> {
<Unresolved name: HttpRequests>#.<Unresolved name: request>#(R|<local>/url|).<Unresolved name: connect>#(<L> = connect@fun <implicit>.<anonymous>(): <ERROR TYPE REF: Unresolved name: fromJson> {
<Unresolved name: GsonBuilder>#().<Unresolved name: create>#().<Unresolved name: fromJson>#(<Unresolved name: it>#.<Unresolved name: inputStream>#.<Ambiguity: reader, [kotlin/io/reader, kotlin/io/reader, kotlin/io/reader]>#(), <getClass>(<Inapplicable(PARAMETER_MAPPING_ERROR): [kotlin/Array.Array]>#<R|class error: Symbol not found, for `PluginDTO`|>()).<Inapplicable(WRONG_RECEIVER): [kotlin/jvm/java]>#)
}
)
@@ -36,7 +36,7 @@ FILE: access.kt
^plus String()
}
public final fun R|Foo|.check(): <ERROR TYPE REF: Empty diagnostic> {
public final fun R|Foo|.check(): <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]> {
^check this@R|/Foo|.R|/Foo.abc|().<Inapplicable(INAPPLICABLE): [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]>#(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|<local>/a|
lval d: R|kotlin/String| = String()
lval c: <ERROR TYPE REF: Empty diagnostic> = <Unresolved name: c>#
lval c: <ERROR TYPE REF: Unresolved name: c> = <Unresolved name: c>#
<Unresolved name: abc>#()
local final fun bcd(): R|kotlin/Unit| {
}
@@ -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: <ERROR TYPE REF: Empty diagnostic> = Q|B|.<Unresolved name: D>#
lval z: <ERROR TYPE REF: Unresolved name: D> = Q|B|.<Unresolved name: D>#
}
@@ -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|>(R|<local>/fooImpl|)
lval b: <ERROR TYPE REF: Empty diagnostic> = <Inapplicable(INAPPLICABLE): [/foo]>#(R|<local>/bar|)
lval b: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#(R|<local>/bar|)
}
@@ -17,6 +17,6 @@ FILE: typeParameters2.kt
^foo R|<local>/t|
}
public final fun main(fooImpl: R|FooImpl|, fooBarImpl: R|FooBarImpl|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Empty diagnostic> = <Inapplicable(INAPPLICABLE): [/foo]>#<R|FooImpl|>(R|<local>/fooBarImpl|)
lval a: <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/foo]> = <Inapplicable(INAPPLICABLE): [/foo]>#<R|FooImpl|>(R|<local>/fooBarImpl|)
lval b: R|Foo| = R|/foo|<R|Foo|>(R|<local>/fooImpl|)
}
+1 -1
View File
@@ -41,7 +41,7 @@ FILE: inner.kt
public final fun test(): R|kotlin/Unit| {
lval o: R|Owner| = R|/Owner.Owner|()
R|<local>/o|.R|/Owner.foo|()
lval err: <ERROR TYPE REF: Empty diagnostic> = Q|Owner|.<Unresolved name: Inner>#()
lval err: <ERROR TYPE REF: Unresolved name: Inner> = Q|Owner|.<Unresolved name: Inner>#()
R|<local>/err|.<Unresolved name: baz>#()
lval i: R|Owner.Inner| = R|<local>/o|.R|/Owner.Inner.Inner|()
R|<local>/i|.R|/Owner.Inner.gau|()
@@ -9,7 +9,7 @@ FILE: nestedClassContructor.kt
super<R|A|>()
}
public final fun copy(): <ERROR TYPE REF: Empty diagnostic> {
public final fun copy(): <ERROR TYPE REF: Ambiguity: B, [/A.B.B, /A.B.B]> {
^copy <Ambiguity: B, [/A.B.B, /A.B.B]>#()
}
@@ -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(): <ERROR TYPE REF: Empty diagnostic> {
public final fun loop1(): <ERROR TYPE REF: Inapplicable(INAPPLICABLE): [/use]> {
^loop1 <Inapplicable(INAPPLICABLE): [/use]>#(::R|/loop2|)
}
public final fun loop2(): <ERROR TYPE REF: cycle> {
@@ -8,15 +8,15 @@ FILE: test.kt
public final fun test(e: R|MyException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|kotlin/printStackTrace|()
R|<local>/e|.R|kotlin/printStackTrace|(R|<local>/stream|)
lval result: <ERROR TYPE REF: Empty diagnostic> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
lval result: <ERROR TYPE REF: Unresolved name: getLocalizedMessage> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
}
public final fun test(e: R|YourException|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|kotlin/printStackTrace|()
R|<local>/e|.R|kotlin/printStackTrace|(R|<local>/stream|)
lval result: <ERROR TYPE REF: Empty diagnostic> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
lval result: <ERROR TYPE REF: Unresolved name: getLocalizedMessage> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
}
public final fun test(e: R|kotlin/Exception|, stream: R|java/io/PrintStream|): R|kotlin/Unit| {
R|<local>/e|.R|kotlin/printStackTrace|()
R|<local>/e|.R|kotlin/printStackTrace|(R|<local>/stream|)
lval result: <ERROR TYPE REF: Empty diagnostic> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
lval result: <ERROR TYPE REF: Unresolved name: getLocalizedMessage> = R|<local>/e|.<Unresolved name: getLocalizedMessage>#()
}
@@ -2,11 +2,11 @@ FILE: test.kt
public abstract interface UseIterable : R|MyIterable<kotlin/String>| {
public open fun test(): R|kotlin/Unit| {
lval it: R|kotlin/collections/MutableIterator<kotlin/String>| = this@R|kotlin/collections/MutableIterable|.R|FakeOverride<kotlin/collections/MutableIterable.iterator: R|kotlin/collections/MutableIterator<kotlin/String>|>|()
lval split: <ERROR TYPE REF: Empty diagnostic> = <Unresolved name: spliterator>#()
lval split: <ERROR TYPE REF: Unresolved name: spliterator> = <Unresolved name: spliterator>#()
}
}
public final fun test(some: R|kotlin/collections/Iterable<kotlin/String>|): R|kotlin/Unit| {
lval it: R|kotlin/collections/Iterator<kotlin/String>| = R|<local>/some|.R|FakeOverride<kotlin/collections/Iterable.iterator: R|kotlin/collections/Iterator<kotlin/String>|>|()
lval split: <ERROR TYPE REF: Empty diagnostic> = R|<local>/some|.<Unresolved name: spliterator>#()
lval split: <ERROR TYPE REF: Unresolved name: spliterator> = R|<local>/some|.<Unresolved name: spliterator>#()
}
+2 -2
View File
@@ -5,7 +5,7 @@ FILE: test.kt
}
)
lval otherResult: R|kotlin/String| = R|<local>/map|.R|FakeOverride<kotlin/collections/Map.getOrDefault: R|kotlin/String|>|(String(key), String(value))
lval anotherResult: <ERROR TYPE REF: Empty diagnostic> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value))
lval anotherResult: <ERROR TYPE REF: Unresolved name: replace> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value))
R|<local>/map|.<Inapplicable(INAPPLICABLE): [kotlin/collections/forEach]>#(<L> = forEach@fun <implicit>.<anonymous>(key: <ERROR TYPE REF: Unsupported: implicit VP type>, value: <ERROR TYPE REF: Unsupported: implicit VP type>): R|kotlin/Unit| {
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
}
@@ -23,7 +23,7 @@ FILE: test.kt
}
)
lval otherResult: R|kotlin/String| = R|<local>/map|.R|FakeOverride<kotlin/collections/Map.getOrDefault: R|kotlin/String|>|(String(key), String(value))
lval anotherResult: <ERROR TYPE REF: Empty diagnostic> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value))
lval anotherResult: <ERROR TYPE REF: Unresolved name: replace> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value))
R|<local>/map|.<Inapplicable(INAPPLICABLE): [kotlin/collections/forEach]>#(<L> = forEach@fun <implicit>.<anonymous>(key: <ERROR TYPE REF: Unsupported: implicit VP type>, value: <ERROR TYPE REF: Unsupported: implicit VP type>): R|kotlin/Unit| {
R|kotlin/io/println|(<strcat>(R|<local>/key|, String(: ), R|<local>/value|))
}
@@ -5,5 +5,5 @@ FILE: reflectionClass.kt
public get(): R|kotlin/reflect/KClass<kotlin/String>|
public final fun foo(): R|kotlin/Unit| {
lval stringClass: R|java/lang/Class<kotlin/String>| = <getClass>(Q|kotlin/String|).R|kotlin/jvm/java|
lval arrayStringClass: <ERROR TYPE REF: Empty diagnostic> = <getClass>(<Inapplicable(PARAMETER_MAPPING_ERROR): [kotlin/Array.Array]>#<R|kotlin/String|>()).<Inapplicable(WRONG_RECEIVER): [kotlin/jvm/java]>#
lval arrayStringClass: <ERROR TYPE REF: Inapplicable(WRONG_RECEIVER): [kotlin/jvm/java]> = <getClass>(<Inapplicable(PARAMETER_MAPPING_ERROR): [kotlin/Array.Array]>#<R|kotlin/String|>()).<Inapplicable(WRONG_RECEIVER): [kotlin/jvm/java]>#
}
@@ -7,19 +7,19 @@ FILE: simpleDelegatedToMap.kt
public final val map: R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>| = R|<local>/map|
public get(): R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>|
public final var foo: <ERROR TYPE REF: Empty diagnostic>by R|<local>/map|
public get(): <ERROR TYPE REF: Empty diagnostic> {
public final var foo: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>by R|<local>/map|
public get(): <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]> {
^ D|/C.foo|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(this@R|/C|, ::R|/C.foo|)
}
public set(<set-?>: <ERROR TYPE REF: Empty diagnostic>): R|kotlin/Unit| {
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
D|/C.foo|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(this@R|/C|, ::R|/C.foo|, R|<local>/foo|)
}
}
public final var bar: <ERROR TYPE REF: Empty diagnostic>by R|kotlin/collections/hashMapOf|<R|kotlin/String|, R|kotlin/Any|>()
public get(): <ERROR TYPE REF: Empty diagnostic> {
public final var bar: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>by R|kotlin/collections/hashMapOf|<R|kotlin/String|, R|kotlin/Any|>()
public get(): <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]> {
^ D|/bar|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(Null(null), ::R|/bar|)
}
public set(<set-?>: <ERROR TYPE REF: Empty diagnostic>): R|kotlin/Unit| {
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
D|/bar|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(Null(null), ::R|/bar|, R|<local>/bar|)
}
@@ -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!!
@@ -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
}