[FIR] Improve debugging of diagnostic ranges
`UNREACHABLE_CODE` is weird. If we look into its positioning strategy, we'll see that this diagnostic attempts to split the source of its element into multiple ranges. This is bad, because such smaller ranges can easily overlap with other diagnostics in such a way that they are no longer hierarchical. See the `compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.kt` test for an example of this behavior (allow reporting `UNREACHABLE_CODE` first). The problem will appear at the condition of `case_7`.
This commit is contained in:
committed by
Space Team
parent
7541732752
commit
110cc79ddd
+6
@@ -61,6 +61,12 @@ object CodeMetaInfoRenderer {
|
||||
|
||||
while (current != null) {
|
||||
val next: CodeMetaInfo? = if (iterator.hasNext()) iterator.next() else null
|
||||
val outer = opened.lastOrNull()
|
||||
if (outer != null) {
|
||||
require(current.end <= outer.end) {
|
||||
"The outer diagnostic ${outer.tag} at ${outer.start} ends at ${outer.end}, but the supposedly inner ${current?.tag} starting at ${current?.start} ends at ${current?.end}. Rendered so far:\n$builder"
|
||||
}
|
||||
}
|
||||
opened.push(current)
|
||||
builder.append(current.asString())
|
||||
when {
|
||||
|
||||
Reference in New Issue
Block a user