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

Skip to content

Commit 2bdcc10

Browse files
committed
Add test for adapter function
1 parent 712b680 commit 2bdcc10

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

java/ql/test/kotlin/library-tests/reflection/PrintAst.expected

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,49 @@ reflection.kt:
206206
# 103| 0: [Parameter] l
207207
# 103| 1: [Parameter] l2
208208
# 103| 5: [BlockStmt] { ... }
209+
# 121| 9: [Method] fn1
210+
# 121| 5: [BlockStmt] { ... }
211+
# 121| 0: [ReturnStmt] return ...
212+
# 121| 0: [IntegerLiteral] 5
213+
# 123| 10: [Method] fn2
214+
#-----| 4: (Parameters)
215+
# 123| 0: [Parameter] f
216+
# 123| 5: [BlockStmt] { ... }
217+
# 123| 0: [ReturnStmt] return ...
218+
# 123| 0: [MethodAccess] invoke(...)
219+
# 123| -1: [VarAccess] f
220+
# 125| 11: [Method] adapted
221+
# 125| 5: [BlockStmt] { ... }
222+
# 126| 0: [ExprStmt] <Expr>;
223+
# 126| 0: [MethodAccess] fn2(...)
224+
# 126| -1: [TypeAccess] ReflectionKt
225+
# 126| 0: [StmtExpr] <Stmt>
226+
# 126| 0: [BlockStmt] { ... }
227+
# 126| 0: [LocalTypeDeclStmt] class ...
228+
# 126| 0: [LocalClass]
229+
# 126| 1: [Constructor]
230+
# 126| 5: [BlockStmt] { ... }
231+
# 126| 0: [SuperConstructorInvocationStmt] super(...)
232+
# 126| 1: [Method] fn1
233+
# 126| 5: [BlockStmt] { ... }
234+
# 126| 0: [ExprStmt] <Expr>;
235+
# 126| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
236+
# 126| 0: [TypeAccess] Unit
237+
# 126| 1: [MethodAccess] fn1(...)
238+
# 126| -1: [TypeAccess] ReflectionKt
239+
# 126| 1: [ExprStmt] <Expr>;
240+
# 126| 0: [MemberRefExpr] ...::...
241+
# 126| -4: [AnonymousClass] new Function0<Unit>(...) { ... }
242+
# 126| 1: [Constructor]
243+
# 126| 5: [BlockStmt] { ... }
244+
# 126| 0: [SuperConstructorInvocationStmt] super(...)
245+
# 126| 1: [Method] invoke
246+
# 126| 5: [BlockStmt] { ... }
247+
# 126| 0: [ReturnStmt] return ...
248+
# 126| 0: [MethodAccess] fn1(...)
249+
# 126| -1: [TypeAccess] ReflectionKt
250+
# 126| -3: [TypeAccess] Function0<Unit>
251+
# 126| 0: [TypeAccess] Unit
209252
# 5| 2: [Class] Reflection
210253
# 5| 1: [Constructor] Reflection
211254
# 5| 5: [BlockStmt] { ... }

java/ql/test/kotlin/library-tests/reflection/reflection.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ functionReferences
5151
| reflection.kt:98:14:98:17 | ...::... | reflection.kt:98:14:98:17 | invoke | reflection.kt:94:1:94:24 | fn |
5252
| reflection.kt:99:14:99:29 | ...::... | reflection.kt:99:14:99:29 | invoke | file://<external>/Class2$Inner.class:0:0:0:0 | Inner<String> |
5353
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | reflection.kt:115:9:115:27 | fn1 |
54+
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | reflection.kt:121:1:121:13 | fn1 |
5455
propertyGetReferences
5556
| reflection.kt:10:38:10:42 | ...::... | reflection.kt:10:38:10:42 | get | reflection.kt:33:9:33:23 | getP0 |
5657
| reflection.kt:15:35:15:41 | ...::... | reflection.kt:15:35:15:41 | get | reflection.kt:33:9:33:23 | getP0 |
@@ -114,6 +115,7 @@ callsInsideInvocationMethods
114115
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:109:17:109:27 | set | reflection.kt:109:17:109:27 | setProp1(...) | Base1.setProp1 |
115116
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | new Function1<Integer,Unit>(...) { ... } | reflection.kt:116:40:116:44 | invoke | reflection.kt:116:40:116:44 | fn1(...) | .fn1 |
116117
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | new Function1<Integer,Unit>(...) { ... } | reflection.kt:116:40:116:44 | invoke | reflection.kt:116:40:116:44 | new (...) | . |
118+
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | new Function0<Unit>(...) { ... } | reflection.kt:126:9:126:13 | invoke | reflection.kt:126:9:126:13 | fn1(...) | ReflectionKt.fn1 |
117119
fieldAccessInsideInvocationMethods
118120
| reflection.kt:14:38:14:44 | ...::... | reflection.kt:14:38:14:44 | new Function1<C,Integer>(...) { ... } | reflection.kt:14:38:14:44 | invoke | reflection.kt:14:38:14:44 | this.<dispatchReceiver> |
119121
| reflection.kt:15:35:15:41 | ...::... | reflection.kt:15:35:15:41 | new KProperty0<Integer>(...) { ... } | reflection.kt:15:35:15:41 | get | reflection.kt:15:35:15:41 | this.<dispatchReceiver> |
@@ -181,3 +183,4 @@ memberVisibility
181183
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | invoke | public |
182184
| reflection.kt:109:17:109:27 | ...::... | reflection.kt:109:17:109:27 | set | public |
183185
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public |
186+
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public |

java/ql/test/kotlin/library-tests/reflection/reflection.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,12 @@ class LocalFn {
116116
val x: KFunction1<Int, Unit> = ::fn1
117117
}
118118
}
119+
120+
121+
fun fn1() = 5
122+
123+
fun fn2(f: () -> Unit) = f()
124+
125+
fun adapted() {
126+
fn2(::fn1)
127+
}

0 commit comments

Comments
 (0)