[JVM_IR] Remove line numbers from delegated member functions.
This fixes smart step into for delegated member functions. Additionally, we align on the string "memberFunctionName(...)" for expression non-null checks for both JVM_IR and JVM backends.
This commit is contained in:
committed by
Alexander Udalov
parent
eea4ff33a0
commit
05c662ec55
+9
-2
@@ -17,7 +17,9 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
@@ -139,8 +141,13 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil
|
||||
irNot(lowerInstanceOf(expression.argument.transformVoid(), expression.typeOperand))
|
||||
|
||||
IrTypeOperator.IMPLICIT_NOTNULL -> {
|
||||
val (startOffset, endOffset) = expression.extents()
|
||||
val source = sourceViewFor(parent as IrDeclaration).subSequence(startOffset, endOffset).toString()
|
||||
val owner = scope.scopeOwnerSymbol.owner
|
||||
val source = if (owner is IrFunction && owner.origin == IrDeclarationOrigin.DELEGATED_MEMBER) {
|
||||
"${owner.name.asString()}(...)"
|
||||
} else {
|
||||
val (startOffset, endOffset) = expression.extents()
|
||||
sourceViewFor(parent as IrDeclaration).subSequence(startOffset, endOffset).toString()
|
||||
}
|
||||
|
||||
irLetS(expression.argument.transformVoid(), irType = context.irBuiltIns.anyNType) { valueSymbol ->
|
||||
irComposite(resultType = expression.type) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi2ir.generators
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrImplementingDelegateDescriptorImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
@@ -305,7 +306,7 @@ class ClassGenerator(
|
||||
delegateToDescriptor: FunctionDescriptor
|
||||
): IrSimpleFunction =
|
||||
context.symbolTable.declareSimpleFunctionWithOverrides(
|
||||
irDelegate.startOffset, irDelegate.endOffset,
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||
IrDeclarationOrigin.DELEGATED_MEMBER,
|
||||
delegatedDescriptor
|
||||
).buildWithScope { irFunction ->
|
||||
@@ -323,8 +324,8 @@ class ClassGenerator(
|
||||
delegateToDescriptor: FunctionDescriptor,
|
||||
irDelegatedFunction: IrSimpleFunction
|
||||
): IrBlockBody {
|
||||
val startOffset = irDelegate.startOffset
|
||||
val endOffset = irDelegate.endOffset
|
||||
val startOffset = UNDEFINED_OFFSET
|
||||
val endOffset = UNDEFINED_OFFSET
|
||||
|
||||
val irBlockBody = context.irFactory.createBlockBody(startOffset, endOffset)
|
||||
|
||||
|
||||
+1
-1
@@ -7,4 +7,4 @@ interface D {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
class C(d: D) : D by <!ACCIDENTAL_OVERRIDE!>d<!>, B
|
||||
class <!ACCIDENTAL_OVERRIDE!>C(d: D)<!> : D by d, B
|
||||
+3
-3
@@ -9,7 +9,7 @@ interface Bar<T> {
|
||||
fun foo(l: List<T>)
|
||||
}
|
||||
|
||||
class Baz(f: Foo<String>, b: Bar<Int>) :
|
||||
Foo<String> by <!CONFLICTING_JVM_DECLARATIONS!>f<!>,
|
||||
Bar<Int> by <!CONFLICTING_JVM_DECLARATIONS!>b<!> {
|
||||
class <!CONFLICTING_JVM_DECLARATIONS!>Baz(f: Foo<String>, b: Bar<Int>)<!> :
|
||||
Foo<String> by f,
|
||||
Bar<Int> by b {
|
||||
}
|
||||
+1
-1
@@ -5,6 +5,6 @@ interface Foo<T> {
|
||||
fun foo(l: List<T>)
|
||||
}
|
||||
|
||||
class Bar(f: Foo<String>): Foo<String> by <!CONFLICTING_JVM_DECLARATIONS!>f<!> {
|
||||
class <!CONFLICTING_JVM_DECLARATIONS!>Bar(f: Foo<String>)<!>: Foo<String> by f {
|
||||
<!CONFLICTING_JVM_DECLARATIONS!>fun foo(l: List<Int>)<!> {}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ interface Foo<T> {
|
||||
}
|
||||
}
|
||||
|
||||
class Bar(f: Foo<String>): Foo<String> by <!CONFLICTING_JVM_DECLARATIONS!>f<!> {
|
||||
class <!CONFLICTING_JVM_DECLARATIONS!>Bar(f: Foo<String>)<!>: Foo<String> by f {
|
||||
<!CONFLICTING_JVM_DECLARATIONS!>fun foo(l: List<Int>)<!> {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ interface B {
|
||||
fun foo(l: List<Int>) {}
|
||||
}
|
||||
|
||||
class C(f: A<String>): A<String> by <!ACCIDENTAL_OVERRIDE!>f<!>, B
|
||||
class <!ACCIDENTAL_OVERRIDE!>C(f: A<String>)<!>: A<String> by f, B
|
||||
|
||||
<!DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE!>class D<!>(f: A<Int>): A<Int> by f, B
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
LineBreakpoint created at smartStepIntoWithDelegates.kt:24
|
||||
LineBreakpoint created at smartStepIntoWithDelegates.kt:32
|
||||
LineBreakpoint created at smartStepIntoWithDelegates.kt:40
|
||||
|
||||
Reference in New Issue
Block a user