Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2320553

Browse files
committed
Kotlin: Add tests for this
1 parent 87e8425 commit 2320553

5 files changed

Lines changed: 132 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| this.kt:2:1:53:1 | <obinit>(...) | this.kt:2:1:53:1 | <obinit> |
2+
| this.kt:2:1:53:1 | super(...) | file://:0:0:0:0 | Any |
3+
| this.kt:3:5:48:5 | <obinit>(...) | this.kt:3:5:48:5 | <obinit> |
4+
| this.kt:3:5:48:5 | super(...) | file://:0:0:0:0 | Any |
5+
| this.kt:31:13:31:25 | topLevelFun(...) | this.kt:54:1:54:20 | topLevelFun |
6+
| this.kt:32:13:32:22 | outerFun(...) | this.kt:49:5:49:21 | outerFun |
7+
| this.kt:33:13:33:22 | innerFun(...) | this.kt:44:9:44:25 | innerFun |
8+
| this.kt:34:13:34:30 | topLevelOuterFun(...) | this.kt:50:5:50:29 | topLevelOuterFun |
9+
| this.kt:35:13:35:30 | topLevelInnerFun(...) | this.kt:45:9:45:33 | topLevelInnerFun |
10+
| this.kt:36:13:36:27 | outerInnerFun(...) | this.kt:46:9:46:30 | outerInnerFun |
11+
| this.kt:37:13:37:35 | topLevelOuterInnerFun(...) | this.kt:47:9:47:38 | topLevelOuterInnerFun |
12+
| this.kt:38:18:38:27 | innerFun(...) | this.kt:44:9:44:25 | innerFun |
13+
| this.kt:39:18:39:35 | topLevelInnerFun(...) | this.kt:45:9:45:33 | topLevelInnerFun |
14+
| this.kt:40:18:40:32 | outerInnerFun(...) | this.kt:46:9:46:30 | outerInnerFun |
15+
| this.kt:41:18:41:40 | topLevelOuterInnerFun(...) | this.kt:47:9:47:38 | topLevelOuterInnerFun |
16+
| this.kt:59:1:60:1 | <obinit>(...) | this.kt:59:1:60:1 | <obinit> |
17+
| this.kt:59:1:60:1 | super(...) | file://:0:0:0:0 | Any |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import java
2+
3+
from Call c
4+
select c, c.getCallee()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| this.kt:5:29:5:32 | this | file://:0:0:0:0 | <none> |
2+
| this.kt:6:29:6:38 | this | file://:0:0:0:0 | <none> |
3+
| this.kt:7:29:7:38 | this | file://:0:0:0:0 | <none> |
4+
| this.kt:24:38:24:41 | this | file://:0:0:0:0 | <none> |
5+
| this.kt:25:29:25:38 | this | file://:0:0:0:0 | <none> |
6+
| this.kt:26:29:26:38 | this | file://:0:0:0:0 | <none> |
7+
| this.kt:27:38:27:54 | this | file://:0:0:0:0 | <none> |
8+
| this.kt:32:13:32:22 | this | file://:0:0:0:0 | <none> |
9+
| this.kt:33:13:33:22 | this | file://:0:0:0:0 | <none> |
10+
| this.kt:34:13:34:30 | this | file://:0:0:0:0 | <none> |
11+
| this.kt:35:13:35:30 | this | file://:0:0:0:0 | <none> |
12+
| this.kt:36:13:36:27 | this | file://:0:0:0:0 | <none> |
13+
| this.kt:37:13:37:35 | this | file://:0:0:0:0 | <none> |
14+
| this.kt:38:13:38:16 | this | file://:0:0:0:0 | <none> |
15+
| this.kt:39:13:39:16 | this | file://:0:0:0:0 | <none> |
16+
| this.kt:40:13:40:16 | this | file://:0:0:0:0 | <none> |
17+
| this.kt:41:13:41:16 | this | file://:0:0:0:0 | <none> |
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
class Outer {
3+
inner class Inner {
4+
fun someFun() {
5+
val x1: Inner = this
6+
val x2: Inner = this@Inner
7+
val x3: Outer = this@Outer
8+
9+
val labelledExtensionFun = someLabelledExtensionFun@ fun ExtensionClass.() {
10+
val x4: ExtensionClass = this
11+
val x5: ExtensionClass = this@someLabelledExtensionFun
12+
}
13+
14+
val unLabelledExtensionFun = fun ExtensionClass.() {
15+
val x6: ExtensionClass = this
16+
}
17+
18+
val someLambda = { i: Int ->
19+
val x7: Inner = this
20+
}
21+
}
22+
23+
fun ExtensionClass.extensionFun() {
24+
val x1: ExtensionClass = this
25+
val x2: Inner = this@Inner
26+
val x3: Outer = this@Outer
27+
val x4: ExtensionClass = this@extensionFun
28+
}
29+
30+
fun innerCaller() {
31+
topLevelFun()
32+
outerFun()
33+
innerFun()
34+
topLevelOuterFun()
35+
topLevelInnerFun()
36+
outerInnerFun()
37+
topLevelOuterInnerFun()
38+
this.innerFun()
39+
this.topLevelInnerFun()
40+
this.outerInnerFun()
41+
this.topLevelOuterInnerFun()
42+
}
43+
44+
fun innerFun() {}
45+
fun topLevelInnerFun() {}
46+
fun outerInnerFun() {}
47+
fun topLevelOuterInnerFun() {}
48+
}
49+
fun outerFun() {}
50+
fun topLevelOuterFun() {}
51+
fun outerInnerFun() {}
52+
fun topLevelOuterInnerFun() {}
53+
}
54+
fun topLevelFun() {}
55+
fun topLevelOuterFun() {}
56+
fun topLevelInnerFun() {}
57+
fun topLevelOuterInnerFun() {}
58+
59+
class ExtensionClass {
60+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java
2+
3+
newtype TMaybeElement =
4+
TElement(Element e) or
5+
TNoElement()
6+
7+
class MaybeElement extends TMaybeElement {
8+
abstract string toString();
9+
abstract Location getLocation();
10+
}
11+
12+
class YesMaybeElement extends MaybeElement {
13+
Element e;
14+
15+
YesMaybeElement() { this = TElement(e) }
16+
override string toString() { result = e.toString() }
17+
override Location getLocation() { result = e.getLocation() }
18+
}
19+
20+
class NoMaybeElement extends MaybeElement {
21+
NoMaybeElement() { this = TNoElement() }
22+
23+
override string toString() { result = "<none>" }
24+
override Location getLocation() { none() }
25+
}
26+
27+
MaybeElement qualifier(ThisAccess t) {
28+
if exists(t.getQualifier())
29+
then result = TElement(t.getQualifier())
30+
else result = TNoElement()
31+
}
32+
33+
from ThisAccess t
34+
select t, qualifier(t)

0 commit comments

Comments
 (0)