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

Skip to content

Commit 415fcaf

Browse files
tamasvajkigfoo
authored andcommitted
Add generic constructor reference test
1 parent b228ac4 commit 415fcaf

3 files changed

Lines changed: 96 additions & 0 deletions

File tree

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,67 @@ reflection.kt:
7777
# 54| 0: [ReturnStmt] return ...
7878
# 54| 0: [MethodAccess] toString(...)
7979
# 54| -1: [ThisAccess] this
80+
# 79| 5: [Method] fn
81+
#-----| 2: (Generic Parameters)
82+
# 79| 0: [TypeVariable] T
83+
#-----| 4: (Parameters)
84+
# 79| 0: [Parameter] value
85+
# 79| 5: [BlockStmt] { ... }
86+
# 81| 6: [Method] test
87+
# 81| 5: [BlockStmt] { ... }
88+
# 82| 0: [ExprStmt] <Expr>;
89+
# 82| 0: [MethodAccess] fn11(...)
90+
# 82| -3: [TypeAccess] Class2<String>
91+
# 82| 0: [TypeAccess] String
92+
# 82| -2: [TypeAccess] String
93+
# 82| 0: [StringLiteral]
94+
# 82| 1: [MemberRefExpr] ...::...
95+
# 82| -4: [AnonymousClass] new Function1<String,Class2<String>>(...) { ... }
96+
# 82| 1: [Constructor]
97+
# 82| 5: [BlockStmt] { ... }
98+
# 82| 0: [SuperConstructorInvocationStmt] super(...)
99+
# 82| 1: [Method] invoke
100+
#-----| 4: (Parameters)
101+
# 82| 0: [Parameter] a0
102+
# 82| 5: [BlockStmt] { ... }
103+
# 82| 0: [ReturnStmt] return ...
104+
# 82| 0: [ClassInstanceExpr] new Class2<T>(...)
105+
# 82| -3: [TypeAccess] Class2<T>
106+
# 82| 0: [TypeAccess] String
107+
# 82| 0: [VarAccess] a0
108+
# 82| -3: [TypeAccess] Function1<String,Class2<String>>
109+
# 82| 0: [TypeAccess] String
110+
# 82| 1: [TypeAccess] Class2<String>
111+
# 82| 0: [TypeAccess] String
112+
# 83| 1: [ExprStmt] <Expr>;
113+
# 83| 0: [MethodAccess] fn11(...)
114+
# 83| -3: [TypeAccess] Unit
115+
# 83| -2: [TypeAccess] String
116+
# 83| 0: [StringLiteral]
117+
# 83| 1: [MemberRefExpr] ...::...
118+
# 83| -4: [AnonymousClass] new Function1<String,Unit>(...) { ... }
119+
# 83| 1: [Constructor]
120+
# 83| 5: [BlockStmt] { ... }
121+
# 83| 0: [SuperConstructorInvocationStmt] super(...)
122+
# 83| 1: [Method] invoke
123+
#-----| 4: (Parameters)
124+
# 83| 0: [Parameter] a0
125+
# 83| 5: [BlockStmt] { ... }
126+
# 83| 0: [ReturnStmt] return ...
127+
# 83| 0: [MethodAccess] fn(...)
128+
# 83| -2: [TypeAccess] String
129+
# 83| 0: [VarAccess] a0
130+
# 83| -3: [TypeAccess] Function1<String,Unit>
131+
# 83| 0: [TypeAccess] String
132+
# 83| 1: [TypeAccess] Unit
133+
# 86| 7: [Method] fn11
134+
#-----| 2: (Generic Parameters)
135+
# 86| 0: [TypeVariable] T
136+
# 86| 1: [TypeVariable] R
137+
#-----| 4: (Parameters)
138+
# 86| 0: [Parameter] l
139+
# 86| 1: [Parameter] transform
140+
# 86| 5: [BlockStmt] { ... }
80141
# 3| 2: [Class] Reflection
81142
# 3| 1: [Constructor] Reflection
82143
# 3| 5: [BlockStmt] { ... }
@@ -660,3 +721,23 @@ reflection.kt:
660721
# 73| 5: [BlockStmt] { ... }
661722
# 73| 0: [ReturnStmt] return ...
662723
# 73| 0: [VarAccess] INSTANCE
724+
# 77| 4: [Class,GenericType,ParameterizedType] Class2
725+
#-----| -2: (Generic Parameters)
726+
# 77| 0: [TypeVariable] T
727+
# 77| 1: [Constructor] Class2
728+
#-----| 4: (Parameters)
729+
# 77| 0: [Parameter] value
730+
# 77| 5: [BlockStmt] { ... }
731+
# 77| 0: [SuperConstructorInvocationStmt] super(...)
732+
# 77| 1: [BlockStmt] { ... }
733+
# 77| 0: [ExprStmt] <Expr>;
734+
# 77| 0: [KtInitializerAssignExpr] ...=...
735+
# 77| 0: [VarAccess] value
736+
# 77| 2: [Method] getValue
737+
# 77| 5: [BlockStmt] { ... }
738+
# 77| 0: [ReturnStmt] return ...
739+
# 77| 0: [VarAccess] this.value
740+
# 77| -1: [ThisAccess] this
741+
# 77| 2: [FieldDeclaration] T value;
742+
# 77| -1: [TypeAccess] T
743+
# 77| 0: [VarAccess] value

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ functionReferences
4444
| reflection.kt:61:17:61:36 | ...::... | reflection.kt:61:17:61:36 | invoke | reflection.kt:52:1:52:52 | ext1 |
4545
| reflection.kt:62:17:62:34 | ...::... | reflection.kt:62:17:62:34 | invoke | reflection.kt:54:1:54:48 | ext2 |
4646
| reflection.kt:63:17:63:36 | ...::... | reflection.kt:63:17:63:36 | invoke | reflection.kt:54:1:54:48 | ext2 |
47+
| reflection.kt:82:14:82:21 | ...::... | reflection.kt:82:14:82:21 | invoke | reflection.kt:77:1:77:33 | Class2<T> |
48+
| reflection.kt:83:14:83:17 | ...::... | reflection.kt:83:14:83:17 | invoke | reflection.kt:79:1:79:24 | fn |
4749
propertyGetReferences
4850
| reflection.kt:8:38:8:42 | ...::... | reflection.kt:8:38:8:42 | get | reflection.kt:31:9:31:23 | getP0 |
4951
| reflection.kt:13:35:13:41 | ...::... | reflection.kt:13:35:13:41 | get | reflection.kt:31:9:31:23 | getP0 |
@@ -80,3 +82,5 @@ callsInsideInvocationMethods
8082
| reflection.kt:65:17:65:32 | ...::... | reflection.kt:65:17:65:32 | new KMutableProperty1<Generic<Integer>,Integer>(...) { ... } | reflection.kt:65:17:65:32 | set | reflection.kt:65:17:65:32 | setP2(...) | Generic<Integer>.setP2 |
8183
| reflection.kt:66:17:66:34 | ...::... | reflection.kt:66:17:66:34 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:66:17:66:34 | get | reflection.kt:66:17:66:34 | getP2(...) | Generic<Integer>.getP2 |
8284
| reflection.kt:66:17:66:34 | ...::... | reflection.kt:66:17:66:34 | new KMutableProperty0<Integer>(...) { ... } | reflection.kt:66:17:66:34 | set | reflection.kt:66:17:66:34 | setP2(...) | Generic<Integer>.setP2 |
85+
| reflection.kt:82:14:82:21 | ...::... | reflection.kt:82:14:82:21 | new Function1<String,Class2<String>>(...) { ... } | reflection.kt:82:14:82:21 | invoke | reflection.kt:82:14:82:21 | new Class2<T>(...) | Class2<T>.Class2<T> |
86+
| reflection.kt:83:14:83:17 | ...::... | reflection.kt:83:14:83:17 | new Function1<String,Unit>(...) { ... } | reflection.kt:83:14:83:17 | invoke | reflection.kt:83:14:83:17 | fn(...) | ReflectionKt.fn |

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,14 @@ class Class1 {
7373
set(value) = Unit
7474
}
7575
}
76+
77+
class Class2<T>(val value: T) { }
78+
79+
fun <T> fn(value: T) { }
80+
81+
fun test() {
82+
fn11("", ::Class2)
83+
fn11("", ::fn)
84+
}
85+
86+
fun <T, R> fn11(l: T, transform: (T) -> R) { }

0 commit comments

Comments
 (0)