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

Skip to content

Commit b7faa33

Browse files
tamasvajkigfoo
authored andcommitted
Fix constructor call type access
1 parent b7e0828 commit b7faa33

7 files changed

Lines changed: 44 additions & 29 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,10 +1807,22 @@ open class KotlinFileExtractor(
18071807
extractExpressionExpr(dr, callable, id, -2)
18081808
}
18091809

1810+
val typeAccessType = if (isAnonymous) {
1811+
val c = (e.type as IrSimpleType).classifier.owner as IrClass
1812+
if (c.superTypes.size == 1) {
1813+
useType(c.superTypes.first())
1814+
} else {
1815+
useType(pluginContext.irBuiltIns.anyType)
1816+
}
1817+
} else {
1818+
type
1819+
}
1820+
1821+
val typeAccessId = tw.getFreshIdLabel<DbUnannotatedtypeaccess>()
1822+
tw.writeExprs_unannotatedtypeaccess(typeAccessId, typeAccessType.javaResult.id, typeAccessType.kotlinResult.id, id, -3)
1823+
tw.writeCallableEnclosingExpr(typeAccessId, callable)
1824+
18101825
if (e.typeArgumentsCount > 0) {
1811-
val typeAccessId = tw.getFreshIdLabel<DbUnannotatedtypeaccess>()
1812-
tw.writeExprs_unannotatedtypeaccess(typeAccessId, type.javaResult.id, type.kotlinResult.id, id, -3)
1813-
tw.writeCallableEnclosingExpr(typeAccessId, callable)
18141826
extractTypeArguments(e, typeAccessId, callable)
18151827
}
18161828
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
| classes.kt:66:20:66:54 | (no string representation) | classes.kt:66:20:66:54 | new <no name provided>(...) |
2-
| classes.kt:68:20:68:74 | (no string representation) | classes.kt:68:20:68:74 | new <no name provided>(...) |
3-
| classes.kt:72:16:77:10 | (no string representation) | classes.kt:72:16:77:10 | new <no name provided>(...) |
4-
| classes.kt:75:24:75:33 | (no string representation) | classes.kt:75:24:75:33 | new <no name provided>(...) |
5-
| classes.kt:81:16:81:38 | (no string representation) | classes.kt:81:16:81:38 | new <no name provided>(...) |
6-
| classes.kt:85:16:85:25 | (no string representation) | classes.kt:85:16:85:25 | new <no name provided>(...) |
7-
| classes.kt:89:16:89:44 | (no string representation) | classes.kt:89:16:89:44 | new <no name provided>(...) |
1+
| classes.kt:66:20:66:54 | new Object(...) { ... } | classes.kt:66:20:66:54 | new <no name provided>(...) | file://:0:0:0:0 | Object |
2+
| classes.kt:68:20:68:74 | new Object(...) { ... } | classes.kt:68:20:68:74 | new <no name provided>(...) | file://:0:0:0:0 | Object |
3+
| classes.kt:72:16:77:10 | new Object(...) { ... } | classes.kt:72:16:77:10 | new <no name provided>(...) | file://:0:0:0:0 | Object |
4+
| classes.kt:75:24:75:33 | new Object(...) { ... } | classes.kt:75:24:75:33 | new <no name provided>(...) | file://:0:0:0:0 | Object |
5+
| classes.kt:81:16:81:38 | new Interface1(...) { ... } | classes.kt:81:16:81:38 | new <no name provided>(...) | file://:0:0:0:0 | Interface1 |
6+
| classes.kt:85:16:85:25 | new Object(...) { ... } | classes.kt:85:16:85:25 | new <no name provided>(...) | file://:0:0:0:0 | Object |
7+
| classes.kt:89:16:89:44 | new Interface3<Integer>(...) { ... } | classes.kt:89:16:89:44 | new <no name provided>(...) | file://:0:0:0:0 | Interface3<Integer> |

java/ql/test/kotlin/library-tests/classes/anonymousClasses.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import java
22

33
from AnonymousClass c
44
where c.fromSource()
5-
select c, c.getClassInstanceExpr()
5+
select c, c.getClassInstanceExpr(), c.getClassInstanceExpr().getTypeName()
66

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
| classes.kt:49:1:51:1 | Direction | Direction |
1010
| classes.kt:53:1:57:1 | Color | Color |
1111
| classes.kt:63:1:91:1 | Class1 | Class1 |
12-
| classes.kt:66:20:66:54 | (no string representation) | <anonymous class> |
13-
| classes.kt:68:20:68:74 | (no string representation) | <anonymous class> |
14-
| classes.kt:72:16:77:10 | (no string representation) | <anonymous class> |
15-
| classes.kt:75:24:75:33 | (no string representation) | <anonymous class> |
16-
| classes.kt:81:16:81:38 | (no string representation) | <anonymous class> |
17-
| classes.kt:85:16:85:25 | (no string representation) | <anonymous class> |
18-
| classes.kt:89:16:89:44 | (no string representation) | <anonymous class> |
12+
| classes.kt:66:20:66:54 | new Object(...) { ... } | <anonymous class> |
13+
| classes.kt:68:20:68:74 | new Object(...) { ... } | <anonymous class> |
14+
| classes.kt:72:16:77:10 | new Object(...) { ... } | <anonymous class> |
15+
| classes.kt:75:24:75:33 | new Object(...) { ... } | <anonymous class> |
16+
| classes.kt:81:16:81:38 | new Interface1(...) { ... } | <anonymous class> |
17+
| classes.kt:85:16:85:25 | new Object(...) { ... } | <anonymous class> |
18+
| classes.kt:89:16:89:44 | new Interface3<Integer>(...) { ... } | <anonymous class> |

java/ql/test/kotlin/library-tests/classes/superTypes.expected

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
| classes.kt:49:1:51:1 | Direction | Enum<Direction> | Enum.class | 0 | 0 | 0 | 0 |
1111
| classes.kt:53:1:57:1 | Color | Enum<Color> | Enum.class | 0 | 0 | 0 | 0 |
1212
| classes.kt:63:1:91:1 | Class1 | Object | Object.class | 0 | 0 | 0 | 0 |
13-
| classes.kt:66:20:66:54 | (no string representation) | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
14-
| classes.kt:66:20:66:54 | (no string representation) | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
15-
| classes.kt:68:20:68:74 | (no string representation) | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
16-
| classes.kt:68:20:68:74 | (no string representation) | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
17-
| classes.kt:68:20:68:74 | (no string representation) | Interface3<String> | classes.kt | 61 | 1 | 61 | 26 |
18-
| classes.kt:72:16:77:10 | (no string representation) | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
19-
| classes.kt:72:16:77:10 | (no string representation) | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
20-
| classes.kt:75:24:75:33 | (no string representation) | Object | Object.class | 0 | 0 | 0 | 0 |
21-
| classes.kt:81:16:81:38 | (no string representation) | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
22-
| classes.kt:85:16:85:25 | (no string representation) | Object | Object.class | 0 | 0 | 0 | 0 |
23-
| classes.kt:89:16:89:44 | (no string representation) | Interface3<Integer> | classes.kt | 61 | 1 | 61 | 26 |
13+
| classes.kt:66:20:66:54 | new Object(...) { ... } | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
14+
| classes.kt:66:20:66:54 | new Object(...) { ... } | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
15+
| classes.kt:68:20:68:74 | new Object(...) { ... } | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
16+
| classes.kt:68:20:68:74 | new Object(...) { ... } | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
17+
| classes.kt:68:20:68:74 | new Object(...) { ... } | Interface3<String> | classes.kt | 61 | 1 | 61 | 26 |
18+
| classes.kt:72:16:77:10 | new Object(...) { ... } | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
19+
| classes.kt:72:16:77:10 | new Object(...) { ... } | Interface2 | classes.kt | 60 | 1 | 60 | 23 |
20+
| classes.kt:75:24:75:33 | new Object(...) { ... } | Object | Object.class | 0 | 0 | 0 | 0 |
21+
| classes.kt:81:16:81:38 | new Interface1(...) { ... } | Interface1 | classes.kt | 59 | 1 | 59 | 23 |
22+
| classes.kt:85:16:85:25 | new Object(...) { ... } | Object | Object.class | 0 | 0 | 0 | 0 |
23+
| classes.kt:89:16:89:44 | new Interface3<Integer>(...) { ... } | Interface3<Integer> | classes.kt | 61 | 1 | 61 | 26 |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@
241241
| exprs.kt:113:31:113:37 | ... + ... | exprs.kt:112:16:114:9 | <obinit> | AddExpr |
242242
| exprs.kt:113:36:113:37 | a2 | exprs.kt:112:16:114:9 | <obinit> | VarAccess |
243243
| exprs.kt:113:40:113:49 | toString(...) | exprs.kt:112:16:114:9 | <obinit> | MethodAccess |
244+
| file://:0:0:0:0 | C | exprs.kt:66:5:66:33 | foo | TypeAccess |
244245
| file://:0:0:0:0 | Color | exprs.kt:95:6:99:1 | Color | TypeAccess |
245246
| file://:0:0:0:0 | Direction | exprs.kt:91:6:93:1 | Direction | TypeAccess |
247+
| file://:0:0:0:0 | Interface1 | exprs.kt:110:13:115:5 | getObject | TypeAccess |
246248
| file://:0:0:0:0 | height | exprs.kt:82:1:89:1 | foo | VarAccess |
247249
| file://:0:0:0:0 | q | exprs.kt:73:1:80:1 | typeTests | VarAccess |
248250
| file://:0:0:0:0 | q | exprs.kt:73:1:80:1 | typeTests | VarAccess |

java/ql/test/kotlin/library-tests/stmts/exprs.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| file://:0:0:0:0 | Exception | TypeAccess |
12
| file://:0:0:0:0 | z | VarAccess |
23
| file://:0:0:0:0 | z | VarAccess |
34
| file://:0:0:0:0 | z | VarAccess |

0 commit comments

Comments
 (0)