Skip to content

Commit afeea64

Browse files
committed
Kotlin: Add test case for overloaded array get
1 parent 74cd532 commit afeea64

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
test.kt:
2+
# 0| [CompilationUnit] test
3+
# 0| 1: [Class] TestKt
4+
# 1| 1: [Method] fn
5+
# 1| 3: [TypeAccess] Unit
6+
#-----| 4: (Parameters)
7+
# 1| 0: [Parameter] arr
8+
# 1| 0: [TypeAccess] byte[]
9+
# 1| 1: [Parameter] mt
10+
# 1| 0: [TypeAccess] C
11+
# 1| 5: [BlockStmt] { ... }
12+
# 2| 0: [ExprStmt] <Expr>;
13+
# 2| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
14+
# 2| 0: [TypeAccess] Unit
15+
# 2| 1: [ArrayAccess] ...[...]
16+
# 2| 0: [VarAccess] arr
17+
# 2| 1: [IntegerLiteral] 1
18+
# 3| 1: [ExprStmt] <Expr>;
19+
# 3| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
20+
# 3| 0: [TypeAccess] Unit
21+
# 3| 1: [ArrayAccess] ...[...]
22+
# 3| 1: [IntegerLiteral] 1
23+
# 4| 2: [ExprStmt] <Expr>;
24+
# 4| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
25+
# 4| 0: [TypeAccess] Unit
26+
# 4| 1: [MethodAccess] get(...)
27+
# 4| -1: [VarAccess] mt
28+
# 4| 0: [IntegerLiteral] 1
29+
# 4| 1: [IntegerLiteral] 2
30+
# 7| 2: [ExtensionMethod] get
31+
# 7| 3: [TypeAccess] String
32+
#-----| 4: (Parameters)
33+
# 7| 0: [Parameter] <this>
34+
# 7| 0: [TypeAccess] byte[]
35+
# 7| 1: [Parameter] i
36+
# 7| 0: [TypeAccess] int
37+
# 7| 2: [Parameter] j
38+
# 7| 0: [TypeAccess] int
39+
# 7| 5: [BlockStmt] { ... }
40+
# 7| 0: [ReturnStmt] return ...
41+
# 7| 0: [StringLiteral]
42+
# 10| 2: [Class] C
43+
# 10| 1: [Constructor] C
44+
# 10| 5: [BlockStmt] { ... }
45+
# 10| 0: [SuperConstructorInvocationStmt] super(...)
46+
# 10| 1: [BlockStmt] { ... }
47+
# 11| 2: [Method] get
48+
# 11| 3: [TypeAccess] String
49+
#-----| 4: (Parameters)
50+
# 11| 0: [Parameter] i
51+
# 11| 0: [TypeAccess] int
52+
# 11| 1: [Parameter] j
53+
# 11| 0: [TypeAccess] int
54+
# 11| 5: [BlockStmt] { ... }
55+
# 11| 0: [ReturnStmt] return ...
56+
# 11| 0: [StringLiteral]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle/code/java/PrintAst.ql
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| test.kt:3:5:3:13 | Dispatch receiver not found |
2+
| test.kt:3:5:3:13 | Extra arguments found |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fun fn(arr: ByteArray, mt: C) {
2+
arr[1]
3+
arr[1, 2]
4+
mt[1, 2]
5+
}
6+
7+
public operator fun ByteArray.get(i: Int, j: Int) = ""
8+
9+
10+
public class C {
11+
public operator fun get(i: Int, j: Int) = ""
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import java
2+
import java
3+
import semmle.code.java.Diagnostics
4+
5+
from Diagnostic d
6+
select d

0 commit comments

Comments
 (0)