mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Kotlin: Add a Kotlin 2 copy of the testsuite
This commit is contained in:
23
java/ql/test-kotlin2/library-tests/this/call.expected
Normal file
23
java/ql/test-kotlin2/library-tests/this/call.expected
Normal file
@@ -0,0 +1,23 @@
|
||||
| this.kt:2:1:58:1 | super(...) | Object |
|
||||
| this.kt:3:5:53:5 | super(...) | Object |
|
||||
| this.kt:9:66:17:13 | ...->... | |
|
||||
| this.kt:9:66:17:13 | super(...) | Object |
|
||||
| this.kt:12:82:16:17 | ...->... | |
|
||||
| this.kt:12:82:16:17 | super(...) | Object |
|
||||
| this.kt:19:42:21:13 | ...->... | |
|
||||
| this.kt:19:42:21:13 | super(...) | Object |
|
||||
| this.kt:23:30:25:13 | ...->... | |
|
||||
| this.kt:23:30:25:13 | super(...) | Object |
|
||||
| this.kt:36:13:36:25 | topLevelFun(...) | topLevelFun |
|
||||
| this.kt:37:13:37:22 | outerFun(...) | outerFun |
|
||||
| this.kt:38:13:38:22 | innerFun(...) | innerFun |
|
||||
| this.kt:39:13:39:30 | topLevelOuterFun(...) | topLevelOuterFun |
|
||||
| this.kt:40:13:40:30 | topLevelInnerFun(...) | topLevelInnerFun |
|
||||
| this.kt:41:13:41:27 | outerInnerFun(...) | outerInnerFun |
|
||||
| this.kt:42:13:42:35 | topLevelOuterInnerFun(...) | topLevelOuterInnerFun |
|
||||
| this.kt:43:13:43:27 | innerFun(...) | innerFun |
|
||||
| this.kt:44:13:44:35 | topLevelInnerFun(...) | topLevelInnerFun |
|
||||
| this.kt:45:13:45:32 | outerInnerFun(...) | outerInnerFun |
|
||||
| this.kt:46:13:46:40 | topLevelOuterInnerFun(...) | topLevelOuterInnerFun |
|
||||
| this.kt:64:1:65:1 | super(...) | Object |
|
||||
| this.kt:67:1:68:1 | super(...) | Object |
|
||||
4
java/ql/test-kotlin2/library-tests/this/call.ql
Normal file
4
java/ql/test-kotlin2/library-tests/this/call.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import java
|
||||
|
||||
from Call c
|
||||
select c, c.getCallee().toString()
|
||||
26
java/ql/test-kotlin2/library-tests/this/this.expected
Normal file
26
java/ql/test-kotlin2/library-tests/this/this.expected
Normal file
@@ -0,0 +1,26 @@
|
||||
#select
|
||||
| this.kt:5:29:5:32 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:6:29:6:38 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:7:29:7:38 | Outer.this | this.kt:7:29:7:38 | Outer |
|
||||
| this.kt:24:34:24:37 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:30:29:30:38 | Inner.this | this.kt:30:29:30:38 | Inner |
|
||||
| this.kt:31:29:31:38 | Outer.this | this.kt:31:29:31:38 | Outer |
|
||||
| this.kt:37:13:37:22 | Outer.this | this.kt:37:13:37:22 | Outer |
|
||||
| this.kt:38:13:38:22 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:39:13:39:30 | Outer.this | this.kt:39:13:39:30 | Outer |
|
||||
| this.kt:40:13:40:30 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:41:13:41:27 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:42:13:42:35 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:43:13:43:16 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:44:13:44:16 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:45:13:45:16 | this | file://:0:0:0:0 | <none> |
|
||||
| this.kt:46:13:46:16 | this | file://:0:0:0:0 | <none> |
|
||||
extensionReceiverAcc
|
||||
| this.kt:10:42:10:45 | this |
|
||||
| this.kt:11:42:11:70 | this |
|
||||
| this.kt:13:53:13:56 | this |
|
||||
| this.kt:14:46:14:74 | this |
|
||||
| this.kt:15:53:15:87 | this |
|
||||
| this.kt:20:42:20:45 | this |
|
||||
| this.kt:29:38:29:41 | this |
|
||||
| this.kt:32:38:32:54 | this |
|
||||
68
java/ql/test-kotlin2/library-tests/this/this.kt
Normal file
68
java/ql/test-kotlin2/library-tests/this/this.kt
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
class Outer {
|
||||
inner class Inner {
|
||||
fun someFun() {
|
||||
val x1: Inner = this
|
||||
val x2: Inner = this@Inner
|
||||
val x3: Outer = this@Outer
|
||||
|
||||
val labelledExtensionFun = someLabelledExtensionFun@ fun ExtensionClass.() {
|
||||
val x4: ExtensionClass = this
|
||||
val x5: ExtensionClass = this@someLabelledExtensionFun
|
||||
val nestedLabelledExtensionFun = someNestedLabelledExtensionFun@ fun AnotherExtensionClass.() {
|
||||
val x6: AnotherExtensionClass = this
|
||||
val x7: ExtensionClass = this@someLabelledExtensionFun
|
||||
val x8: AnotherExtensionClass = this@someNestedLabelledExtensionFun
|
||||
}
|
||||
}
|
||||
|
||||
val unLabelledExtensionFun = fun ExtensionClass.() {
|
||||
val x9: ExtensionClass = this
|
||||
}
|
||||
|
||||
val someLambda = { i: Int ->
|
||||
val x10: Inner = this
|
||||
}
|
||||
}
|
||||
|
||||
fun ExtensionClass.extensionFun() {
|
||||
val x1: ExtensionClass = this
|
||||
val x2: Inner = this@Inner
|
||||
val x3: Outer = this@Outer
|
||||
val x4: ExtensionClass = this@extensionFun
|
||||
}
|
||||
|
||||
fun innerCaller() {
|
||||
topLevelFun()
|
||||
outerFun()
|
||||
innerFun()
|
||||
topLevelOuterFun()
|
||||
topLevelInnerFun()
|
||||
outerInnerFun()
|
||||
topLevelOuterInnerFun()
|
||||
this.innerFun()
|
||||
this.topLevelInnerFun()
|
||||
this.outerInnerFun()
|
||||
this.topLevelOuterInnerFun()
|
||||
}
|
||||
|
||||
fun innerFun() {}
|
||||
fun topLevelInnerFun() {}
|
||||
fun outerInnerFun() {}
|
||||
fun topLevelOuterInnerFun() {}
|
||||
}
|
||||
fun outerFun() {}
|
||||
fun topLevelOuterFun() {}
|
||||
fun outerInnerFun() {}
|
||||
fun topLevelOuterInnerFun() {}
|
||||
}
|
||||
fun topLevelFun() {}
|
||||
fun topLevelOuterFun() {}
|
||||
fun topLevelInnerFun() {}
|
||||
fun topLevelOuterInnerFun() {}
|
||||
|
||||
class ExtensionClass {
|
||||
}
|
||||
|
||||
class AnotherExtensionClass {
|
||||
}
|
||||
38
java/ql/test-kotlin2/library-tests/this/this.ql
Normal file
38
java/ql/test-kotlin2/library-tests/this/this.ql
Normal file
@@ -0,0 +1,38 @@
|
||||
import java
|
||||
|
||||
newtype TMaybeElement =
|
||||
TElement(Element e) or
|
||||
TNoElement()
|
||||
|
||||
class MaybeElement extends TMaybeElement {
|
||||
abstract string toString();
|
||||
|
||||
abstract Location getLocation();
|
||||
}
|
||||
|
||||
class YesMaybeElement extends MaybeElement {
|
||||
Element e;
|
||||
|
||||
YesMaybeElement() { this = TElement(e) }
|
||||
|
||||
override string toString() { result = e.toString() }
|
||||
|
||||
override Location getLocation() { result = e.getLocation() }
|
||||
}
|
||||
|
||||
class NoMaybeElement extends MaybeElement {
|
||||
NoMaybeElement() { this = TNoElement() }
|
||||
|
||||
override string toString() { result = "<none>" }
|
||||
|
||||
override Location getLocation() { none() }
|
||||
}
|
||||
|
||||
MaybeElement qualifier(ThisAccess t) {
|
||||
if exists(t.getQualifier()) then result = TElement(t.getQualifier()) else result = TNoElement()
|
||||
}
|
||||
|
||||
from ThisAccess t
|
||||
select t, qualifier(t)
|
||||
|
||||
query predicate extensionReceiverAcc(ExtensionReceiverAccess va) { any() }
|
||||
Reference in New Issue
Block a user