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

Skip to content

Commit 246f228

Browse files
tamasvajkigfoo
authored andcommitted
Add static field access test
1 parent f43296a commit 246f228

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

java/ql/test/kotlin/library-tests/exprs_typeaccess/A.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class A {
1717
fun fn(i: Int) : Int {
1818
val x = this.fn(1)
1919
val e = Enu.A
20-
return 5
20+
return B.x
2121
}
2222

2323
enum class Enu {

java/ql/test/kotlin/library-tests/exprs_typeaccess/B.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public void fn() { }
88
public int fn(int i) {
99
int x = this.fn(1);
1010
Enu e = Enu.A;
11-
return 5;
11+
return B.x;
1212
}
1313

1414
public static class C<T> {
@@ -20,4 +20,6 @@ public void fn() {
2020
public static enum Enu {
2121
A, B, C
2222
}
23+
24+
public static final int x = 5;
2325
}

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ A.kt:
7171
# 19| 0: [VarAccess] Enu.A
7272
# 19| -1: [TypeAccess] Enu
7373
# 20| 2: [ReturnStmt] return ...
74-
# 20| 0: [IntegerLiteral] 5
74+
# 20| 0: [VarAccess] x
7575
# 23| 11: [Class] Enu
7676
# 0| 1: [Method] values
7777
# 0| 3: [TypeAccess] Enu[]
@@ -97,13 +97,13 @@ A.kt:
9797
B.java:
9898
# 0| [CompilationUnit] B
9999
# 1| 1: [Class] B
100-
# 2| 1: [Constructor] B
100+
# 2| 2: [Constructor] B
101101
# 2| 5: [BlockStmt] { ... }
102102
# 3| 1: [EmptyStmt] ;
103-
# 6| 2: [Method] fn
103+
# 6| 3: [Method] fn
104104
# 6| 3: [TypeAccess] void
105105
# 6| 5: [BlockStmt] { ... }
106-
# 7| 3: [Method] fn
106+
# 7| 4: [Method] fn
107107
# 7| 3: [TypeAccess] C<C<Integer>>
108108
# 7| 0: [TypeAccess] C<Integer>
109109
# 7| 0: [TypeAccess] Integer
@@ -115,7 +115,7 @@ B.java:
115115
# 7| 5: [BlockStmt] { ... }
116116
# 7| 0: [ReturnStmt] return ...
117117
# 7| 0: [VarAccess] i
118-
# 8| 4: [Method] fn
118+
# 8| 5: [Method] fn
119119
# 8| 3: [TypeAccess] int
120120
#-----| 4: (Parameters)
121121
# 8| 0: [Parameter] i
@@ -133,8 +133,9 @@ B.java:
133133
# 10| 0: [VarAccess] Enu.A
134134
# 10| -1: [TypeAccess] Enu
135135
# 11| 2: [ReturnStmt] return ...
136-
# 11| 0: [IntegerLiteral] 5
137-
# 14| 5: [Class,GenericType,ParameterizedType] C
136+
# 11| 0: [VarAccess] B.x
137+
# 11| -1: [TypeAccess] B
138+
# 14| 6: [Class,GenericType,ParameterizedType] C
138139
#-----| -2: (Generic Parameters)
139140
# 14| 0: [TypeVariable] T
140141
# 15| 2: [Method] fn
@@ -145,7 +146,7 @@ B.java:
145146
# 16| -3: [TypeAccess] C<C<Integer>>
146147
# 16| 0: [TypeAccess] C<Integer>
147148
# 16| 0: [TypeAccess] Integer
148-
# 20| 6: [Class] Enu
149+
# 20| 7: [Class] Enu
149150
# 21| 3: [FieldDeclaration] Enu A;
150151
# 21| -1: [TypeAccess] Enu
151152
# 21| 0: [ClassInstanceExpr] new Enu(...)
@@ -158,3 +159,6 @@ B.java:
158159
# 21| -1: [TypeAccess] Enu
159160
# 21| 0: [ClassInstanceExpr] new Enu(...)
160161
# 21| -3: [TypeAccess] Enu
162+
# 24| 8: [FieldDeclaration] int x;
163+
# 24| -1: [TypeAccess] int
164+
# 24| 0: [IntegerLiteral] 5

0 commit comments

Comments
 (0)