Fix source information mapping in PsiSourceManager

Add tests for source information mapping

KT-17108 source information corrupted on PSI -> IR transformation
This commit is contained in:
Dmitry Petrov
2017-03-28 14:40:35 +03:00
parent 4086a84622
commit 2a97fb17ba
9 changed files with 218 additions and 6 deletions
@@ -0,0 +1,23 @@
package test
class Host {
operator fun plusAssign(x: Int) {}
fun test1() {
this += 1
}
}
fun foo() = Host()
fun Host.test2() {
this += 1
}
fun test3() {
foo() += 1
}
fun test4(a: () -> Host) {
a() += 1
}
@@ -0,0 +1,33 @@
@0:0..23:0 FILE /augmentedAssignmentWithExpression.kt
@2:0..8:1 CLASS CLASS Host
@2:0..8:1 CONSTRUCTOR public constructor Host()
@2:0..8:1 BLOCK_BODY
@2:0..8:1 DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
@2:0..8:1 INSTANCE_INITIALIZER_CALL classDescriptor='Host'
@3:4..38 FUN public final operator fun plusAssign(x: kotlin.Int): kotlin.Unit
@3:36..38 BLOCK_BODY
@5:4..7:5 FUN public final fun test1(): kotlin.Unit
@5:16..7:5 BLOCK_BODY
@6:8..17 CALL 'plusAssign(Int): Unit' type=kotlin.Unit origin=PLUSEQ
@6:8..12 GET_VAR '<receiver: Host>' type=test.Host origin=null
@6:16..17 CONST Int type=kotlin.Int value='1'
@10:0..18 FUN public fun foo(): test.Host
@10:12..18 BLOCK_BODY
@10:12..18 RETURN type=kotlin.Nothing from='foo(): Host'
@10:12..18 CALL 'constructor Host()' type=test.Host origin=null
@12:0..14:1 FUN public fun test.Host.test2(): kotlin.Unit
@12:17..14:1 BLOCK_BODY
@13:4..13 CALL 'plusAssign(Int): Unit' type=kotlin.Unit origin=PLUSEQ
@13:4..8 GET_VAR '<receiver: test2() on Host: Unit>' type=test.Host origin=null
@13:12..13 CONST Int type=kotlin.Int value='1'
@16:0..18:1 FUN public fun test3(): kotlin.Unit
@16:12..18:1 BLOCK_BODY
@17:4..14 CALL 'plusAssign(Int): Unit' type=kotlin.Unit origin=PLUSEQ
@17:4..9 CALL 'foo(): Host' type=test.Host origin=null
@17:13..14 CONST Int type=kotlin.Int value='1'
@20:0..22:1 FUN public fun test4(a: () -> test.Host): kotlin.Unit
@20:25..22:1 BLOCK_BODY
@21:4..12 CALL 'plusAssign(Int): Unit' type=kotlin.Unit origin=PLUSEQ
@21:4..7 CALL 'invoke(): Host' type=test.Host origin=INVOKE
@21:4..5 GET_VAR 'value-parameter a: () -> Host' type=() -> test.Host origin=VARIABLE_AS_FUNCTION
@21:11..12 CONST Int type=kotlin.Int value='1'
+27
View File
@@ -0,0 +1,27 @@
/**
* Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are
* represented as values of the primitive type `boolean`.
*/
public interface Boolean {
/**
* Returns the inverse of this boolean.
*/
public operator fun not(): Boolean
/**
* Performs a logical `and` operation between this Boolean and the [other] one.
*/
infix fun and(other: Boolean): Boolean
/**
* Performs a logical `or` operation between this Boolean and the [other] one.
*/
infix fun or(other: Boolean): Boolean
/**
* Performs a logical `xor` operation between this Boolean and the [other] one.
*/
infix fun xor(other: Boolean): Boolean
fun compareTo(other: Boolean): Int
}
+7
View File
@@ -0,0 +1,7 @@
@0:0..26:1 FILE /kt17108.kt
@0:0..26:1 CLASS INTERFACE Boolean
@5:4..8:38 FUN public abstract operator fun not(): Boolean
@10:4..13:42 FUN public abstract infix fun and(other: Boolean): Boolean
@15:4..18:41 FUN public abstract infix fun or(other: Boolean): Boolean
@20:4..23:42 FUN public abstract infix fun xor(other: Boolean): Boolean
@25:4..38 FUN public abstract fun compareTo(other: Boolean): kotlin.Int