FE: drop DiagnosticReporter.context.report & rename reportAndCommit
This commit is contained in:
committed by
Space Team
parent
1826d9b332
commit
d00af1c932
+9
-29
@@ -58,47 +58,27 @@ open class KtDiagnosticReporterWithContext(
|
||||
override val languageVersionSettings: LanguageVersionSettings
|
||||
get() = this@KtDiagnosticReporterWithContext.languageVersionSettings
|
||||
|
||||
@OptIn(InternalDiagnosticFactoryMethod::class)
|
||||
fun report(
|
||||
factory: KtDiagnosticFactory0,
|
||||
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
|
||||
) {
|
||||
sourceElement?.let { report(factory.on(it, positioningStrategy), this) }
|
||||
}
|
||||
|
||||
@OptIn(InternalDiagnosticFactoryMethod::class)
|
||||
fun <A : Any> report(
|
||||
factory: KtDiagnosticFactory1<A>,
|
||||
a: A,
|
||||
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
|
||||
) {
|
||||
sourceElement?.let { report(factory.on(it, a, positioningStrategy), this) }
|
||||
}
|
||||
|
||||
@OptIn(InternalDiagnosticFactoryMethod::class)
|
||||
fun <A1 : Any, A2 : Any> report(
|
||||
factory: KtDiagnosticFactory2<A1, A2>,
|
||||
a1: A1,
|
||||
a2: A2,
|
||||
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
|
||||
) {
|
||||
sourceElement?.let { report(factory.on(it, a1, a2, positioningStrategy), this) }
|
||||
}
|
||||
|
||||
fun reportAndCommit(factory: KtDiagnosticFactory0) {
|
||||
fun report(factory: KtDiagnosticFactory0) {
|
||||
sourceElement?.let {
|
||||
reportOn(it, factory, this)
|
||||
checkAndCommitReportsOn(it, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun <A : Any> reportAndCommit(factory: KtDiagnosticFactory1<A>, a: A) {
|
||||
fun <A : Any> report(factory: KtDiagnosticFactory1<A>, a: A) {
|
||||
sourceElement?.let {
|
||||
reportOn(it, factory, a, this)
|
||||
checkAndCommitReportsOn(it, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun <A : Any, B : Any> report(factory: KtDiagnosticFactory2<A, B>, a: A, b: B) {
|
||||
sourceElement?.let {
|
||||
reportOn(it, factory, a, b, this)
|
||||
checkAndCommitReportsOn(it, this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is DiagnosticContextImpl) return false
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner.OperationKind.SAFE
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
|
||||
import org.jetbrains.kotlin.codegen.pseudoInsns.fakeAlwaysFalseIfeq
|
||||
import org.jetbrains.kotlin.codegen.pseudoInsns.fixStackAndJump
|
||||
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
@@ -874,7 +873,7 @@ class ExpressionCodegen(
|
||||
|
||||
private fun generateGlobalReturnFlagIfPossible(expression: IrExpression, label: String) {
|
||||
if (state.isInlineDisabled) {
|
||||
context.ktDiagnosticReporter.at(expression, irFunction).reportAndCommit(BackendErrors.NON_LOCAL_RETURN_IN_DISABLED_INLINE)
|
||||
context.ktDiagnosticReporter.at(expression, irFunction).report(BackendErrors.NON_LOCAL_RETURN_IN_DISABLED_INLINE)
|
||||
genThrow(mv, "java/lang/UnsupportedOperationException", "Non-local returns are not allowed with inlining disabled")
|
||||
} else {
|
||||
generateGlobalReturnFlag(mv, label)
|
||||
|
||||
+2
-2
@@ -119,12 +119,12 @@ class IrInlineIntrinsicsSupport(
|
||||
override fun toKotlinType(type: IrType): KotlinType = type.toIrBasedKotlinType()
|
||||
|
||||
override fun reportSuspendTypeUnsupported() {
|
||||
classCodegen.context.ktDiagnosticReporter.at(reportErrorsOn, containingFile).reportAndCommit(JvmBackendErrors.TYPEOF_SUSPEND_TYPE)
|
||||
classCodegen.context.ktDiagnosticReporter.at(reportErrorsOn, containingFile).report(JvmBackendErrors.TYPEOF_SUSPEND_TYPE)
|
||||
}
|
||||
|
||||
override fun reportNonReifiedTypeParameterWithRecursiveBoundUnsupported(typeParameterName: Name) {
|
||||
classCodegen.context.ktDiagnosticReporter.at(reportErrorsOn, containingFile)
|
||||
.reportAndCommit(JvmBackendErrors.TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND, typeParameterName.asString())
|
||||
.report(JvmBackendErrors.TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND, typeParameterName.asString())
|
||||
}
|
||||
|
||||
override fun rewritePluginDefinedOperationMarker(v: InstructionAdapter, reifiedInsn: AbstractInsnNode, instructions: InsnList, type: IrType): Boolean {
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ class IrSourceCompilerForInline(
|
||||
override fun reportSuspensionPointInsideMonitor(stackTraceElement: String) {
|
||||
codegen.context.ktDiagnosticReporter
|
||||
.at(callElement.symbol.owner as IrDeclaration)
|
||||
.reportAndCommit(JvmBackendErrors.SUSPENSION_POINT_INSIDE_MONITOR, stackTraceElement)
|
||||
.report(JvmBackendErrors.SUSPENSION_POINT_INSIDE_MONITOR, stackTraceElement)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ class JvmSignatureClashDetector(
|
||||
irDeclarations.mapNotNullTo(LinkedHashSet()) { irDeclaration ->
|
||||
classCodegen.context.ktDiagnosticReporter.atFirstValidFrom(irDeclaration, classCodegen.irClass, containingIrFile = irDeclaration.file)
|
||||
}.forEach {
|
||||
it.reportAndCommit(diagnosticFactory1, conflictingJvmDeclarationsData)
|
||||
it.report(diagnosticFactory1, conflictingJvmDeclarationsData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -33,12 +33,12 @@ class ConstEvaluationLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
override fun lower(irFile: IrFile) {
|
||||
fun onError(element: IrElement, error: IrErrorExpression) {
|
||||
context.ktDiagnosticReporter.at(element, irFile)
|
||||
.reportAndCommit(JvmBackendErrors.EXCEPTION_IN_CONST_VAL_INITIALIZER, error.description)
|
||||
.report(JvmBackendErrors.EXCEPTION_IN_CONST_VAL_INITIALIZER, error.description)
|
||||
}
|
||||
|
||||
fun onWarning(element: IrElement, warning: IrErrorExpression) {
|
||||
context.ktDiagnosticReporter.at(element, irFile)
|
||||
.reportAndCommit(JvmBackendErrors.EXCEPTION_IN_CONST_EXPRESSION, warning.description)
|
||||
.report(JvmBackendErrors.EXCEPTION_IN_CONST_EXPRESSION, warning.description)
|
||||
}
|
||||
|
||||
val suppressErrors = context.configuration.getBoolean(JVMConfigurationKeys.IGNORE_CONST_OPTIMIZATION_ERRORS)
|
||||
|
||||
+4
-2
@@ -127,7 +127,9 @@ private class ScriptsToClassesLowering(val context: JvmBackendContext, val inner
|
||||
declaration.isEnumClass -> reportError(JvmBackendErrors.SCRIPT_CAPTURING_ENUM)
|
||||
declaration.isEnumEntry -> reportError(JvmBackendErrors.SCRIPT_CAPTURING_ENUM_ENTRY)
|
||||
// TODO: ClosureAnnotator is not catching companion's closures, so the following reporting never happens. Make it work or drop
|
||||
declaration.isCompanion -> reportError(JvmBackendErrors.SCRIPT_CAPTURING_OBJECT, SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT)
|
||||
declaration.isCompanion -> reportError(
|
||||
JvmBackendErrors.SCRIPT_CAPTURING_OBJECT, SpecialNames.DEFAULT_NAME_FOR_COMPANION_OBJECT
|
||||
)
|
||||
declaration.kind.isSingleton -> reportError(JvmBackendErrors.SCRIPT_CAPTURING_OBJECT)
|
||||
|
||||
declaration.isClass ->
|
||||
@@ -201,7 +203,7 @@ private class ScriptsToClassesLowering(val context: JvmBackendContext, val inner
|
||||
irScriptClass.thisReceiver = scriptTransformer.scriptClassReceiver
|
||||
|
||||
val defaultContext = ScriptToClassTransformerContext(irScriptClass.thisReceiver?.symbol, null, null, false)
|
||||
fun <E: IrElement> E.patchForClass(): IrElement {
|
||||
fun <E : IrElement> E.patchForClass(): IrElement {
|
||||
return transform(scriptTransformer, defaultContext)
|
||||
.transform(lambdaPatcher, ScriptFixLambdasTransformerContext())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user