[PL] Fix: Don't use locations in compiler messages
^KT-58837
This commit is contained in:
committed by
Space Team
parent
9f12dae117
commit
a01a6b64ad
+4
-5
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.linkage.partial.PartialLinkageConfig
|
||||
import org.jetbrains.kotlin.ir.linkage.partial.PartialLinkageLogLevel
|
||||
import org.jetbrains.kotlin.ir.linkage.partial.PartialLinkageLogger
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.allUnbound
|
||||
@@ -22,19 +22,18 @@ fun createPartialLinkageSupportForLinker(
|
||||
builtIns: IrBuiltIns,
|
||||
messageLogger: IrMessageLogger
|
||||
): PartialLinkageSupportForLinker = if (partialLinkageConfig.isEnabled)
|
||||
PartialLinkageSupportForLinkerImpl(builtIns, allowErrorTypes, partialLinkageConfig.logLevel, messageLogger)
|
||||
PartialLinkageSupportForLinkerImpl(builtIns, allowErrorTypes, PartialLinkageLogger(messageLogger, partialLinkageConfig.logLevel))
|
||||
else
|
||||
PartialLinkageSupportForLinker.DISABLED
|
||||
|
||||
internal class PartialLinkageSupportForLinkerImpl(
|
||||
builtIns: IrBuiltIns,
|
||||
allowErrorTypes: Boolean,
|
||||
logLevel: PartialLinkageLogLevel,
|
||||
messageLogger: IrMessageLogger
|
||||
logger: PartialLinkageLogger
|
||||
) : PartialLinkageSupportForLinker {
|
||||
private val stubGenerator = MissingDeclarationStubGenerator(builtIns)
|
||||
private val classifierExplorer = ClassifierExplorer(builtIns, stubGenerator, allowErrorTypes)
|
||||
private val patcher = PartiallyLinkedIrTreePatcher(builtIns, classifierExplorer, stubGenerator, logLevel, messageLogger)
|
||||
private val patcher = PartiallyLinkedIrTreePatcher(builtIns, classifierExplorer, stubGenerator, logger)
|
||||
|
||||
override val isEnabled get() = true
|
||||
|
||||
|
||||
+3
-10
@@ -23,14 +23,13 @@ fun createPartialLinkageSupportForLowerings(
|
||||
builtIns: IrBuiltIns,
|
||||
messageLogger: IrMessageLogger
|
||||
): PartialLinkageSupportForLowerings = if (partialLinkageConfig.isEnabled)
|
||||
PartialLinkageSupportForLoweringsImpl(builtIns, partialLinkageConfig.logLevel, messageLogger)
|
||||
PartialLinkageSupportForLoweringsImpl(builtIns, PartialLinkageLogger(messageLogger, partialLinkageConfig.logLevel))
|
||||
else
|
||||
PartialLinkageSupportForLowerings.DISABLED
|
||||
|
||||
internal class PartialLinkageSupportForLoweringsImpl(
|
||||
private val builtIns: IrBuiltIns,
|
||||
logLevel: PartialLinkageLogLevel,
|
||||
private val messageLogger: IrMessageLogger
|
||||
private val logger: PartialLinkageLogger
|
||||
) : PartialLinkageSupportForLowerings {
|
||||
override val isEnabled get() = true
|
||||
|
||||
@@ -41,12 +40,6 @@ internal class PartialLinkageSupportForLoweringsImpl(
|
||||
var errorMessagesRendered = 0 // Track each rendered error message.
|
||||
private set
|
||||
|
||||
private val irLoggerSeverity = when (logLevel) {
|
||||
PartialLinkageLogLevel.INFO -> IrMessageLogger.Severity.INFO
|
||||
PartialLinkageLogLevel.WARNING -> IrMessageLogger.Severity.WARNING
|
||||
PartialLinkageLogLevel.ERROR -> IrMessageLogger.Severity.ERROR
|
||||
}
|
||||
|
||||
override fun throwLinkageError(
|
||||
partialLinkageCase: PartialLinkageCase,
|
||||
element: IrElement,
|
||||
@@ -77,7 +70,7 @@ internal class PartialLinkageSupportForLoweringsImpl(
|
||||
val errorMessage = renderLinkageError(partialLinkageCase)
|
||||
val locationInSourceCode = file.computeLocationForOffset(element.startOffsetOfFirstDenotableIrElement())
|
||||
|
||||
messageLogger.report(irLoggerSeverity, errorMessage, locationInSourceCode) // It's OK. We log it as a warning.
|
||||
logger.log(errorMessage, locationInSourceCode)
|
||||
|
||||
return errorMessage
|
||||
}
|
||||
|
||||
+2
-3
@@ -43,8 +43,7 @@ internal class PartiallyLinkedIrTreePatcher(
|
||||
private val builtIns: IrBuiltIns,
|
||||
private val classifierExplorer: ClassifierExplorer,
|
||||
private val stubGenerator: MissingDeclarationStubGenerator,
|
||||
logLevel: PartialLinkageLogLevel,
|
||||
private val messageLogger: IrMessageLogger
|
||||
logger: PartialLinkageLogger
|
||||
) {
|
||||
// Avoid revisiting roots that already have been visited.
|
||||
private val visitedModuleFragments = hashSetOf<IrModuleFragment>()
|
||||
@@ -56,7 +55,7 @@ internal class PartiallyLinkedIrTreePatcher(
|
||||
private val IrModuleFragment.shouldBeSkipped: Boolean get() = files.isEmpty() || name.asString() == stdlibModule.name
|
||||
|
||||
// Used only to generate IR expressions that throw linkage errors.
|
||||
private val supportForLowerings by lazy { PartialLinkageSupportForLoweringsImpl(builtIns, logLevel, messageLogger) }
|
||||
private val supportForLowerings by lazy { PartialLinkageSupportForLoweringsImpl(builtIns, logger) }
|
||||
|
||||
fun shouldBeSkipped(declaration: IrDeclaration): Boolean = PLModule.determineModuleFor(declaration).shouldBeSkipped
|
||||
|
||||
|
||||
Reference in New Issue
Block a user