JVM: fix SMAP range extension logic

If `mapLineNumber` was called in non-monotonic order, e.g. N then N+2
then N+1, the first two calls created a range that spans [N; N+2] but
the third call did not reuse it.
This commit is contained in:
pyos
2020-03-25 14:45:37 +01:00
committed by max-kammerer
parent b4d7dfd02c
commit 9d21800d8f
25 changed files with 284 additions and 108 deletions
-1
View File
@@ -47,7 +47,6 @@ Kotlin
test/_1Kt
*L
1#1,26:1
19#1,6:27
*E
// FILE: 2.smap
@@ -25,7 +25,6 @@ Kotlin
test/_1Kt
*L
1#1,9:1
6#1:10
*E
SMAP
@@ -53,7 +53,6 @@ Kotlin
test/_1Kt
*L
1#1,39:1
35#1,2:40
*E
SMAP
@@ -55,7 +55,6 @@ Kotlin
test/_1Kt
*L
1#1,39:1
35#1,2:40
*E
SMAP
@@ -91,7 +91,6 @@ Kotlin
test/_1Kt
*L
1#1,75:1
71#1,2:76
*E
SMAP
@@ -54,7 +54,6 @@ Kotlin
test/_1Kt
*L
1#1,40:1
36#1,2:41
*E
SMAP
@@ -56,7 +56,6 @@ Kotlin
test/_1Kt
*L
1#1,40:1
36#1,2:41
*E
SMAP
@@ -54,7 +54,6 @@ Kotlin
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
@@ -29,7 +29,6 @@ Kotlin
test/_1Kt
*L
1#1,13:1
8#1:14
*E
SMAP
@@ -27,7 +27,6 @@ Kotlin
test/_1Kt
*L
1#1,11:1
8#1:12
*E
SMAP
@@ -52,7 +52,6 @@ Kotlin
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
@@ -36,12 +36,10 @@ test/_1Kt
4#1:19
7#1:21
8#1:23
4#1,6:24
10#1:31
4#1,7:24
4#2:18
4#2:20
4#2:22
4#2:30
*E
*S KotlinDebug
*F
@@ -51,10 +49,8 @@ _2Kt
8#1:19
13#1:21
13#1:23
13#1,6:24
13#1:31
13#1,7:24
7#1:18
9#1:20
13#1:22
13#1:30
*E
@@ -0,0 +1,76 @@
// FILE: 1.kt
package test
inline fun f() {}
inline fun g() {}
inline fun h() {}
inline fun together() {
f() // new range 1.kt:N -> 1.kt:4
h() // new range 1.kt:N+1 -> 1.kt:6 because of different call site
g() // new range 1.kt:N+2 -> 1.kt:5 for the same reason
}
// FILE: 2.kt
import test.*
fun box(): String {
// 1. new range 2.kt:N -> 1.kt:9
// 2. new range 2.kt:N+1 -> 1.kt:4
// 3. extend to 2.kt:N+1..N+7 -> 1.kt:4..10 and use N+7 for 1.kt:10
// 4. use N+2 for 1.kt:5
// 5. extend to 2.kt:N+1..N+8 -> 1.kt:4..11 and use N+8 for 1.kt:11
// 6. use N+3 for 1.kt:6
// 7. extend to 2.kt:N+1..N+9 -> 1.kt:4..12 and use N+9 for 1.kt:12
// steps 4 and 6 *should not* create new ranges
together()
return "OK"
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,14:1
4#1:15
6#1:16
5#1:17
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt
*L
9#1:15
10#1:16
11#1:17
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
*L
1#1,17:1
9#2:18
4#2,9:19
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
13#1:18
13#1,9:19
*E
@@ -0,0 +1,100 @@
// FILE: 1.kt
package test
object A { inline fun f() {} }
object B { inline fun g() {} }
object C { inline fun h() {} }
object D {
inline fun together() {
A.f()
C.h()
B.g()
}
}
// FILE: 2.kt
import test.*
object X {
// Unlike `rangeFolding.kt`, the calls in `D.together` refer to different
// classes which are reflected in the SMAP, so they cannot be joined into
// a single range even in `X.foo`; neither can lines corresponding to
// `D.together` because they do not form an uninterrupted range.
fun foo() = D.together()
}
fun box(): String {
X.foo()
return "OK"
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/D
+ 2 1.kt
test/A
+ 3 1.kt
test/C
+ 4 1.kt
test/B
*L
1#1,16:1
4#2:17
6#3:18
5#4:19
*E
*S KotlinDebug
*F
+ 1 1.kt
test/D
*L
10#1:17
11#1:18
12#1:19
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
X
+ 2 1.kt
test/D
+ 3 1.kt
test/A
+ 4 1.kt
test/C
+ 5 1.kt
test/B
*L
1#1,17:1
10#2:18
11#2:20
12#2:22
13#2:24
4#3:19
6#4:21
5#5:23
*E
*S KotlinDebug
*F
+ 1 2.kt
X
*L
9#1:18
9#1:20
9#1:22
9#1:24
9#1:19
9#1:21
9#1:23
*E
@@ -33,14 +33,12 @@ _2Kt
zzz/_1Kt
*L
1#1,11:1
7#2:12
9#2:13
7#2,3:12
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
6#1:12
6#1:13
6#1,3:12
*E
+22 -26
View File
@@ -80,40 +80,36 @@ _2Kt
builders/_1Kt
*L
1#1,25:1
7#1,3:40
10#1:45
11#1,2:49
13#1:52
15#1:54
7#1,3:36
10#1:41
11#1,2:45
13#1:48
15#1:50
19#2:26
7#2,9:27
11#2,3:36
8#2:39
19#2:43
7#2:44
15#2:46
11#2,2:47
13#2:51
8#2:53
19#2:39
7#2:40
15#2:42
11#2,2:43
13#2:47
8#2:49
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
20#1,3:40
20#1:45
20#1,2:49
20#1:52
20#1:54
20#1,3:36
20#1:41
20#1,2:45
20#1:48
20#1:50
9#1:26
9#1,9:27
9#1,3:36
9#1:39
20#1:43
20#1:44
20#1:46
20#1,2:47
20#1:51
20#1:53
20#1:39
20#1:40
20#1:42
20#1,2:43
20#1:47
20#1:49
*E