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

Skip to content

Commit dcac285

Browse files
tamasvajkigfoo
authored andcommitted
Add type access tests
1 parent 7ef9420 commit dcac285

4 files changed

Lines changed: 188 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
class A {
3+
class C<T> {
4+
fun fn(){
5+
val a = C<C<Int>>()
6+
}
7+
}
8+
9+
constructor() {
10+
println("")
11+
}
12+
13+
val prop = this.fn(1)
14+
15+
fun fn() {}
16+
fun fn(i: C<C<Int>>) = i
17+
fun fn(i: Int) : Int {
18+
val x = this.fn(1)
19+
val e = Enu.A
20+
return 5
21+
}
22+
23+
enum class Enu {
24+
A, B, C
25+
}
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class B {
2+
public B() {
3+
;
4+
}
5+
6+
public void fn() { }
7+
public C<C<Integer>> fn(C<C<Integer>> i) { return i; }
8+
public int fn(int i) {
9+
int x = this.fn(1);
10+
Enu e = Enu.A;
11+
return 5;
12+
}
13+
14+
public static class C<T> {
15+
public void fn() {
16+
new C<C<Integer>>();
17+
}
18+
}
19+
20+
public static enum Enu {
21+
A, B, C
22+
}
23+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
A.kt:
2+
# 0| [CompilationUnit] A
3+
# 2| 1: [Class] A
4+
# 3| 3: [Class,GenericType,ParameterizedType] C
5+
#-----| -2: (Generic Parameters)
6+
# 3| 0: [TypeVariable] T
7+
# 3| 1: [Constructor] C
8+
# 3| 5: [BlockStmt] { ... }
9+
# 3| 0: [SuperConstructorInvocationStmt] super(...)
10+
# 3| 1: [BlockStmt] { ... }
11+
# 4| 2: [Method] fn
12+
# 4| 5: [BlockStmt] { ... }
13+
# 5| 0: [LocalVariableDeclStmt] var ...;
14+
# 5| 1: [LocalVariableDeclExpr] a
15+
# 5| 0: [ClassInstanceExpr] new C<C<Integer>>(...)
16+
# 5| -3: [TypeAccess] C<C<Integer>>
17+
# 5| 0: [TypeAccess] C<Integer>
18+
# 5| 0: [TypeAccess] Integer
19+
# 9| 5: [Constructor] A
20+
# 9| 5: [BlockStmt] { ... }
21+
# 9| 0: [SuperConstructorInvocationStmt] super(...)
22+
# 9| 1: [BlockStmt] { ... }
23+
# 13| 0: [ExprStmt] <Expr>;
24+
# 13| 0: [KtInitializerAssignExpr] ...=...
25+
# 13| 0: [VarAccess] prop
26+
# 10| 2: [ExprStmt] <Expr>;
27+
# 10| 0: [MethodAccess] println(...)
28+
# 10| -1: [TypeAccess] ConsoleKt
29+
# 10| 0: [StringLiteral]
30+
# 13| 6: [Method] getProp
31+
# 13| 5: [BlockStmt] { ... }
32+
# 13| 0: [ReturnStmt] return ...
33+
# 13| 0: [VarAccess] this.prop
34+
# 13| -1: [ThisAccess] this
35+
# 13| 6: [FieldDeclaration] int prop;
36+
# 13| -1: [TypeAccess] int
37+
# 13| 0: [MethodAccess] fn(...)
38+
# 13| -1: [ThisAccess] A.this
39+
# 13| 0: [TypeAccess] A
40+
# 13| 0: [IntegerLiteral] 1
41+
# 15| 8: [Method] fn
42+
# 15| 5: [BlockStmt] { ... }
43+
# 16| 9: [Method] fn
44+
#-----| 4: (Parameters)
45+
# 16| 0: [Parameter] i
46+
# 16| 5: [BlockStmt] { ... }
47+
# 16| 0: [ReturnStmt] return ...
48+
# 16| 0: [VarAccess] i
49+
# 17| 10: [Method] fn
50+
#-----| 4: (Parameters)
51+
# 17| 0: [Parameter] i
52+
# 17| 5: [BlockStmt] { ... }
53+
# 18| 0: [LocalVariableDeclStmt] var ...;
54+
# 18| 1: [LocalVariableDeclExpr] x
55+
# 18| 0: [MethodAccess] fn(...)
56+
# 18| -1: [ThisAccess] this
57+
# 18| 0: [IntegerLiteral] 1
58+
# 19| 1: [LocalVariableDeclStmt] var ...;
59+
# 19| 1: [LocalVariableDeclExpr] e
60+
# 19| 0: [VarAccess] A
61+
# 20| 2: [ReturnStmt] return ...
62+
# 20| 0: [IntegerLiteral] 5
63+
# 23| 11: [Class] Enu
64+
# 0| 1: [Method] values
65+
# 0| 1: [Method] valueOf
66+
#-----| 4: (Parameters)
67+
# 0| 0: [Parameter] value
68+
# 23| 3: [Constructor] Enu
69+
# 23| 5: [BlockStmt] { ... }
70+
# 23| 0: [ExprStmt] <Expr>;
71+
# 23| 0: [ClassInstanceExpr] new Enum(...)
72+
# 23| -3: [TypeAccess] Unit
73+
# 23| 0: [TypeAccess] Enu
74+
# 23| 1: [BlockStmt] { ... }
75+
B.java:
76+
# 0| [CompilationUnit] B
77+
# 1| 1: [Class] B
78+
# 2| 1: [Constructor] B
79+
# 2| 5: [BlockStmt] { ... }
80+
# 3| 1: [EmptyStmt] ;
81+
# 6| 2: [Method] fn
82+
# 6| 3: [TypeAccess] void
83+
# 6| 5: [BlockStmt] { ... }
84+
# 7| 3: [Method] fn
85+
# 7| 3: [TypeAccess] C<C<Integer>>
86+
# 7| 0: [TypeAccess] C<Integer>
87+
# 7| 0: [TypeAccess] Integer
88+
#-----| 4: (Parameters)
89+
# 7| 0: [Parameter] i
90+
# 7| 0: [TypeAccess] C<C<Integer>>
91+
# 7| 0: [TypeAccess] C<Integer>
92+
# 7| 0: [TypeAccess] Integer
93+
# 7| 5: [BlockStmt] { ... }
94+
# 7| 0: [ReturnStmt] return ...
95+
# 7| 0: [VarAccess] i
96+
# 8| 4: [Method] fn
97+
# 8| 3: [TypeAccess] int
98+
#-----| 4: (Parameters)
99+
# 8| 0: [Parameter] i
100+
# 8| 0: [TypeAccess] int
101+
# 8| 5: [BlockStmt] { ... }
102+
# 9| 0: [LocalVariableDeclStmt] var ...;
103+
# 9| 0: [TypeAccess] int
104+
# 9| 1: [LocalVariableDeclExpr] x
105+
# 9| 0: [MethodAccess] fn(...)
106+
# 9| -1: [ThisAccess] this
107+
# 9| 0: [IntegerLiteral] 1
108+
# 10| 1: [LocalVariableDeclStmt] var ...;
109+
# 10| 0: [TypeAccess] Enu
110+
# 10| 1: [LocalVariableDeclExpr] e
111+
# 10| 0: [VarAccess] Enu.A
112+
# 10| -1: [TypeAccess] Enu
113+
# 11| 2: [ReturnStmt] return ...
114+
# 11| 0: [IntegerLiteral] 5
115+
# 14| 5: [Class,GenericType,ParameterizedType] C
116+
#-----| -2: (Generic Parameters)
117+
# 14| 0: [TypeVariable] T
118+
# 15| 2: [Method] fn
119+
# 15| 3: [TypeAccess] void
120+
# 15| 5: [BlockStmt] { ... }
121+
# 16| 0: [ExprStmt] <Expr>;
122+
# 16| 0: [ClassInstanceExpr] new C<C<Integer>>(...)
123+
# 16| -3: [TypeAccess] C<C<Integer>>
124+
# 16| 0: [TypeAccess] C<Integer>
125+
# 16| 0: [TypeAccess] Integer
126+
# 20| 6: [Class] Enu
127+
# 21| 3: [FieldDeclaration] Enu A;
128+
# 21| -1: [TypeAccess] Enu
129+
# 21| 0: [ClassInstanceExpr] new Enu(...)
130+
# 21| -3: [TypeAccess] Enu
131+
# 21| 4: [FieldDeclaration] Enu B;
132+
# 21| -1: [TypeAccess] Enu
133+
# 21| 0: [ClassInstanceExpr] new Enu(...)
134+
# 21| -3: [TypeAccess] Enu
135+
# 21| 5: [FieldDeclaration] Enu C;
136+
# 21| -1: [TypeAccess] Enu
137+
# 21| 0: [ClassInstanceExpr] new Enu(...)
138+
# 21| -3: [TypeAccess] Enu
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle/code/java/PrintAst.ql

0 commit comments

Comments
 (0)