diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt index 6d147cce822..25ec0bd88ce 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt @@ -5,15 +5,32 @@ package org.jetbrains.kotlin.fir.resolve.diagnostics +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.diagnostics.* import org.jetbrains.kotlin.fir.FirSourceElement - -class ConeDiagnosticFactory { - lateinit var name: String - - fun on(source: FirSourceElement): ConeDiagnostic = ConeDiagnostic(this, source) -} +import org.jetbrains.kotlin.fir.psi class ConeDiagnostic( - val factory: ConeDiagnosticFactory, + val diagnostic: Diagnostic, val source: FirSourceElement -) \ No newline at end of file +) + +inline fun DiagnosticFactory0.on(source: FirSourceElement): ConeDiagnostic? { + val psi = source.psi as? E ?: return null + return ConeDiagnostic(this.on(psi), source) +} + +inline fun DiagnosticFactory1.on(source: FirSourceElement, a: A): ConeDiagnostic? { + val psi = source.psi as? E ?: return null + return ConeDiagnostic(this.on(psi, a), source) +} + +inline fun DiagnosticFactory2.on(source: FirSourceElement, a: A, b: B): ConeDiagnostic? { + val psi = source.psi as? E ?: return null + return ConeDiagnostic(this.on(psi, a, b), source) +} + +inline fun DiagnosticFactory3.on(source: FirSourceElement, a: A, b: B, c: C): ConeDiagnostic? { + val psi = source.psi as? E ?: return null + return ConeDiagnostic(this.on(psi, a, b, c), source) +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt deleted file mode 100644 index 45a73298c0b..00000000000 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2019 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.resolve.diagnostics - -import kotlin.reflect.KProperty - -object ConeDiagnostics { - val INFIX_MODIFIER_REQUIRED = ConeDiagnosticFactory() - val INAPPLICABLE_INFIX_MODIFIER = ConeDiagnosticFactory() - - init { - ConeDiagnostics::class.members.filterIsInstance>().forEach { property -> - val factory = property.getter.call(this) as? ConeDiagnosticFactory - factory?.name = property.name - } - } -} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt index 75fe471459a..51462d00128 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt @@ -6,13 +6,14 @@ package org.jetbrains.kotlin.fir.resolve.diagnostics abstract class DiagnosticReporter { - abstract fun report(diagnostic: ConeDiagnostic) + abstract fun report(diagnostic: ConeDiagnostic?) } class SimpleDiagnosticReporter : DiagnosticReporter() { val diagnostics: MutableList = mutableListOf() - override fun report(diagnostic: ConeDiagnostic) { + override fun report(diagnostic: ConeDiagnostic?) { + if (diagnostic == null) return diagnostics += diagnostic } } \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt index b85bb67c7e9..dd8b4919d65 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt @@ -5,11 +5,12 @@ package org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration +import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.isInfix -import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnostics +import org.jetbrains.kotlin.fir.resolve.diagnostics.on import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter object FirInfixFunctionDeclarationChecker : FirDeclarationChecker() { @@ -26,6 +27,6 @@ object FirInfixFunctionDeclarationChecker : FirDeclarationChecker: $text" + "<${it.diagnostic.factory.name}>: $text" } KotlinTestUtils.assertEqualsToFile(expectedFile, actual) }