[IR] Improve stepping/LVT behavior around destructuring
This commit is contained in:
committed by
Alexander Udalov
parent
c3dbb44e5f
commit
7f531d8426
+4
-1
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmIrMangler
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
||||
@@ -24,7 +25,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildClass
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.expressions.IrDelegatingConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
||||
@@ -252,4 +252,7 @@ open class JvmGeneratorExtensionsImpl(
|
||||
|
||||
override val parametersAreAssignable: Boolean
|
||||
get() = true
|
||||
|
||||
override val debugInfoOnlyOnVariablesInDestructuringDeclarations: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
+5
-2
@@ -722,10 +722,10 @@ private class TypeOperatorLowering(private val backendContext: JvmBackendContext
|
||||
val source = if (owner is IrFunction && owner.isDelegated()) {
|
||||
"${owner.name.asString()}(...)"
|
||||
} else {
|
||||
val (startOffset, endOffset) = expression.extents()
|
||||
val declarationParent = parent as? IrDeclaration
|
||||
val sourceView = declarationParent?.let(::sourceViewFor)
|
||||
if (sourceView != null && startOffset >= 0 && endOffset < sourceView.length) {
|
||||
val (startOffset, endOffset) = expression.extents()
|
||||
if (sourceView?.validSourcePosition(startOffset, endOffset) == true) {
|
||||
sourceView.subSequence(startOffset, endOffset).toString()
|
||||
} else {
|
||||
// Fallback for inconsistent line numbers
|
||||
@@ -757,6 +757,9 @@ private class TypeOperatorLowering(private val backendContext: JvmBackendContext
|
||||
origin == IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR ||
|
||||
origin == IrDeclarationOrigin.DELEGATED_MEMBER
|
||||
|
||||
private fun CharSequence.validSourcePosition(startOffset: Int, endOffset: Int): Boolean =
|
||||
startOffset in 0 until endOffset && endOffset < length
|
||||
|
||||
private fun IrElement.extents(): Pair<Int, Int> {
|
||||
var startOffset = Int.MAX_VALUE
|
||||
var endOffset = 0
|
||||
|
||||
Reference in New Issue
Block a user