Kotlin: Add a test for Kotlin seeing Java code as properties

This commit is contained in:
Ian Lynagh
2022-01-17 18:18:55 +00:00
parent 579c590ea6
commit ad33c47536
4 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
Prop.java:
# 0| [CompilationUnit] Prop
# 2| 1: [Class] Prop
# 2| 1: [Constructor] Prop
# 4| 2: [Method] getFoo
# 4| 3: [TypeAccess] String
# 4| 5: [BlockStmt] { ... }
# 5| 0: [ReturnStmt] return ...
# 5| 0: [StringLiteral] "foo"
Use.kt:
# 0| [CompilationUnit] Use
# 0| 1: [Class] UseKt
# 2| 1: [Method] use
#-----| 4: (Parameters)
# 2| 0: [Parameter] prop
# 2| 5: [BlockStmt] { ... }
# 3| 0: [ReturnStmt] return ...
# 3| 0: [CastExpr] (...)...
# 3| 0: [TypeAccess] String
# 3| 1: [MethodAccess] getFoo(...)
# 3| -1: [VarAccess] prop

View File

@@ -0,0 +1 @@
semmle/code/java/PrintAst.ql

View File

@@ -0,0 +1,7 @@
public class Prop {
// This will look like a property in Kotlin
String getFoo() {
return "foo";
}
}

View File

@@ -0,0 +1,4 @@
fun use(prop: Prop): String {
return prop.foo
}