Fix assertion in light tree diagnostic reporter

happened then two diagnostics are reported on the same element.
#KT-55924 fixed
This commit is contained in:
Ilya Chernikov
2023-01-19 15:35:34 +01:00
committed by Space Team
parent 3b9aac067a
commit 7ec72b568d
5 changed files with 31 additions and 1 deletions
@@ -162,10 +162,10 @@ private class SequentialFilePositionFinder(file: File) : Closeable {
// assuming that if called multiple times, calls should be sorted by ascending offset
fun findNextPosition(offset: Int, withLineContents: Boolean = true): KtSourceFilePos {
assert(offset >= charsRead - (currentLineContent?.length ?: 0))
fun posInCurrentLine(): KtSourceFilePos? {
val col = offset - (charsRead - currentLineContent!!.length - 1)/* beginning of line offset */ + 1 /* col is 1-based */
assert(col > 0)
return if (col <= currentLineContent!!.length)
KtSourceFilePos(currentLine, col, if (withLineContents) currentLineContent else null)
else null