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

Skip to content

Commit 70708d6

Browse files
smowtonigfoo
authored andcommitted
Don't extract or call fake-override methods
1 parent 0c7075c commit 70708d6

20 files changed

Lines changed: 95 additions & 268 deletions

File tree

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ open class KotlinFileExtractor(
3434
fun extractDeclaration(declaration: IrDeclaration, parentId: Label<out DbReftype>) {
3535
when (declaration) {
3636
is IrClass -> extractClassSource(declaration)
37-
is IrFunction -> extractFunction(declaration, parentId)
37+
is IrFunction -> extractFunctionIfReal(declaration, parentId)
3838
is IrAnonymousInitializer -> {
3939
// Leaving this intentionally empty. init blocks are extracted during class extraction.
4040
}
@@ -141,7 +141,7 @@ open class KotlinFileExtractor(
141141

142142
c.declarations.map {
143143
when(it) {
144-
is IrFunction -> extractFunction(it, id, false, typeParamSubstitution)
144+
is IrFunction -> extractFunctionIfReal(it, id, false, typeParamSubstitution)
145145
is IrProperty -> extractProperty(it, id, false, typeParamSubstitution)
146146
else -> {}
147147
}
@@ -358,6 +358,12 @@ open class KotlinFileExtractor(
358358
}
359359
}
360360

361+
fun extractFunctionIfReal(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean = true, typeSubstitutionMap: Map<IrTypeParameterSymbol, IrTypeArgument>? = null) {
362+
if (f.origin == IrDeclarationOrigin.FAKE_OVERRIDE)
363+
return
364+
extractFunction(f, parentId, extractBody, typeSubstitutionMap)
365+
}
366+
361367
fun extractFunction(f: IrFunction, parentId: Label<out DbReftype>, extractBody: Boolean = true, typeSubstitutionMap: Map<IrTypeParameterSymbol, IrTypeArgument>? = null): Label<out DbCallable> {
362368
currentFunction = f
363369

@@ -730,7 +736,8 @@ open class KotlinFileExtractor(
730736
isFunction("kotlin", "Double", fName)
731737
}
732738

733-
fun extractMethodAccess(callTarget: IrFunction, extractMethodTypeArguments: Boolean = true, extractClassTypeArguments: Boolean = false) {
739+
fun extractMethodAccess(syntacticCallTarget: IrFunction, extractMethodTypeArguments: Boolean = true, extractClassTypeArguments: Boolean = false) {
740+
val callTarget = syntacticCallTarget.target
734741
val id = tw.getFreshIdLabel<DbMethodaccess>()
735742
val type = useType(c.type)
736743
val locId = tw.getLocation(c)
@@ -2013,7 +2020,7 @@ open class KotlinFileExtractor(
20132020
tw.writeHasLocation(id, locId)
20142021

20152022
// Extract local function as a member
2016-
extractFunction(localFunction, id)
2023+
extractFunctionIfReal(localFunction, id)
20172024

20182025
// Extract constructor
20192026
val unitType = useType(pluginContext.irBuiltIns.unitType)

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ cloneMethods
66
sourceSignatures
77
| arrayCreations.kt:3:1:29:1 | <obinit> | <obinit>() |
88
| arrayCreations.kt:3:1:29:1 | TestArrayCreation | TestArrayCreation() |
9-
| arrayCreations.kt:3:1:29:1 | equals | equals(java.lang.Object) |
10-
| arrayCreations.kt:3:1:29:1 | hashCode | hashCode() |
11-
| arrayCreations.kt:3:1:29:1 | toString | toString() |
129
| arrayCreations.kt:4:3:28:3 | test1 | test1() |
1310
| arrayCreations.kt:22:29:22:33 | | |
1411
| arrayCreations.kt:22:29:22:33 | invoke | invoke(int) |
@@ -22,9 +19,6 @@ sourceSignatures
2219
| arrayCreations.kt:27:24:27:38 | invoke | invoke(int) |
2320
| primitiveArrays.kt:3:1:7:1 | <obinit> | <obinit>() |
2421
| primitiveArrays.kt:3:1:7:1 | Test | Test() |
25-
| primitiveArrays.kt:3:1:7:1 | equals | equals(java.lang.Object) |
26-
| primitiveArrays.kt:3:1:7:1 | hashCode | hashCode() |
27-
| primitiveArrays.kt:3:1:7:1 | toString | toString() |
2822
| primitiveArrays.kt:5:3:5:123 | test | test(java.lang.Integer[],java.lang.Integer[],int[],java.lang.Integer[][],java.lang.Integer[][],int[][]) |
2923
#select
3024
| primitiveArrays.kt:5:12:5:24 | a | file://:0:0:0:0 | Integer[] | Integer | Integer | file://:0:0:0:0 | Kotlin nullable FakeKotlinClass |

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ comments
1010
commentOwners
1111
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | Group |
1212
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | Group |
13-
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | equals |
14-
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | hashCode |
15-
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | other |
16-
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | toString |
1713
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:5:17:46 | members |
1814
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:5:17:46 | members |
1915
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:13:17:46 | getMembers |

java/ql/test/kotlin/library-tests/controlflow/basic/getASuccessor.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
| Test.kt:3:1:80:1 | { ... } | BlockStmt | Test.kt:3:1:80:1 | <obinit> | Method |
88
| Test.kt:3:1:80:1 | { ... } | BlockStmt | Test.kt:3:1:80:1 | super(...) | SuperConstructorInvocationStmt |
99
| Test.kt:3:8:80:1 | Test | Constructor | file://:0:0:0:0 | <none> | <none> |
10-
| Test.kt:3:8:80:1 | equals | Method | file://:0:0:0:0 | <none> | <none> |
11-
| Test.kt:3:8:80:1 | hashCode | Method | file://:0:0:0:0 | <none> | <none> |
12-
| Test.kt:3:8:80:1 | other | Parameter | file://:0:0:0:0 | <none> | <none> |
13-
| Test.kt:3:8:80:1 | toString | Method | file://:0:0:0:0 | <none> | <none> |
1410
| Test.kt:4:2:79:2 | test | Method | file://:0:0:0:0 | <none> | <none> |
1511
| Test.kt:4:13:79:2 | { ... } | BlockStmt | Test.kt:5:3:5:16 | var ...; | LocalVariableDeclStmt |
1612
| Test.kt:5:3:5:16 | int x | LocalVariableDecl | file://:0:0:0:0 | <none> | <none> |
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
| extensions.kt:2:1:4:1 | <obinit> | file://<external>/Unit.class:0:0:0:0 | Unit |
2-
| extensions.kt:2:1:4:1 | equals | file://:0:0:0:0 | boolean |
3-
| extensions.kt:2:1:4:1 | hashCode | file://:0:0:0:0 | int |
4-
| extensions.kt:2:1:4:1 | toString | file://<external>/String.class:0:0:0:0 | String |
52
| extensions.kt:3:5:3:28 | someClassMethod | file://:0:0:0:0 | void |
63
| extensions.kt:5:1:7:1 | <obinit> | file://<external>/Unit.class:0:0:0:0 | Unit |
7-
| extensions.kt:5:1:7:1 | equals | file://:0:0:0:0 | boolean |
8-
| extensions.kt:5:1:7:1 | hashCode | file://:0:0:0:0 | int |
9-
| extensions.kt:5:1:7:1 | toString | file://<external>/String.class:0:0:0:0 | String |
104
| extensions.kt:6:5:6:31 | anotherClassMethod | file://:0:0:0:0 | void |
115
| extensions.kt:9:1:9:26 | someFun | file://:0:0:0:0 | void |
126
| extensions.kt:10:1:10:32 | anotherFun | file://:0:0:0:0 | void |
137
| extensions.kt:12:1:12:26 | bothFun | file://:0:0:0:0 | void |
148
| extensions.kt:13:1:13:29 | bothFun | file://:0:0:0:0 | void |
159
| extensions.kt:15:1:15:50 | bothFunDiffTypes | file://:0:0:0:0 | int |
16-
| extensions.kt:16:1:16:60 | bothFunDiffTypes | file://<external>/String.class:0:0:0:0 | String |
10+
| extensions.kt:16:1:16:60 | bothFunDiffTypes | file://<external>/String.class:0:0:0:0 | String |

java/ql/test/kotlin/library-tests/extensions_recursion/element.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
| test.kt:6:1:10:1 | <obinit>(...) |
1313
| test.kt:6:1:10:1 | Foo |
1414
| test.kt:6:1:10:1 | Foo |
15-
| test.kt:6:1:10:1 | equals |
16-
| test.kt:6:1:10:1 | hashCode |
17-
| test.kt:6:1:10:1 | other |
1815
| test.kt:6:1:10:1 | super(...) |
19-
| test.kt:6:1:10:1 | toString |
2016
| test.kt:6:1:10:1 | { ... } |
2117
| test.kt:6:1:10:1 | { ... } |
2218
| test.kt:6:11:6:11 | T |
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
| otherfile.kt:3:1:3:29 | other | Object | Object.class | 0 |
21
| test.kt:7:3:7:11 | b | String | String.class | 0 |
32
| test.kt:8:3:8:24 | c | List<String> | List.class | 0 |
43
| test.kt:9:3:9:28 | d | List<? extends String> | List.class | 0 |
54
| test.kt:10:3:10:24 | e | DefinedHere<String> | test.kt | 14 |
65
| test.kt:11:3:11:29 | f | DefinedOtherFile<String> | otherfile.kt | 3 |
7-
| test.kt:14:1:14:24 | other | Object | Object.class | 0 |

java/ql/test/kotlin/library-tests/generic-instance-methods/test.expected

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,36 +54,24 @@ refTypes
5454
| Test.java:14:14:14:17 | Test | Test.java:16:22:16:25 | user | user() | No parameters | void | Test.java:14:14:14:17 | Test | Test.java:16:22:16:25 | user |
5555
| test.kt:0:0:0:0 | TestKt | test.kt:12:1:25:1 | user | user() | No parameters | void | test.kt:0:0:0:0 | TestKt | test.kt:12:1:25:1 | user |
5656
| test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | <obinit> | <obinit>() | No parameters | Unit | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | <obinit> |
57-
| test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | equals | equals(java.lang.Object) | Object | boolean | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | equals |
58-
| test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | hashCode | hashCode() | No parameters | int | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | hashCode |
59-
| test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | toString | toString() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | toString |
6057
| test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | getStored | getStored() | No parameters | T | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | getStored |
6158
| test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | setStored | setStored(java.lang.Object) | T | void | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | setStored |
6259
| test.kt:1:1:10:1 | Generic | test.kt:5:3:5:46 | identity2 | identity2(java.lang.Object) | T | T | test.kt:1:1:10:1 | Generic | test.kt:5:3:5:46 | identity2 |
6360
| test.kt:1:1:10:1 | Generic | test.kt:6:3:6:35 | identity | identity(java.lang.Object) | T | T | test.kt:1:1:10:1 | Generic | test.kt:6:3:6:35 | identity |
6461
| test.kt:1:1:10:1 | Generic | test.kt:7:3:7:26 | getter | getter() | No parameters | T | test.kt:1:1:10:1 | Generic | test.kt:7:3:7:26 | getter |
6562
| test.kt:1:1:10:1 | Generic | test.kt:8:3:8:41 | setter | setter(java.lang.Object) | T | void | test.kt:1:1:10:1 | Generic | test.kt:8:3:8:41 | setter |
66-
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:1:1:10:1 | equals | equals(java.lang.Object) | Object | boolean | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | equals |
67-
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:1:1:10:1 | hashCode | hashCode() | No parameters | int | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | hashCode |
68-
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:1:1:10:1 | toString | toString() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | toString |
6963
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:3:3:3:19 | getStored | getStored() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | getStored |
7064
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:3:3:3:19 | setStored | setStored(java.lang.Void) | Void | void | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | setStored |
7165
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:5:3:5:46 | identity2 | identity2(java.lang.Void) | Void | String | test.kt:1:1:10:1 | Generic | test.kt:5:3:5:46 | identity2 |
7266
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:6:3:6:35 | identity | identity(java.lang.Void) | Void | String | test.kt:1:1:10:1 | Generic | test.kt:6:3:6:35 | identity |
7367
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:7:3:7:26 | getter | getter() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:7:3:7:26 | getter |
7468
| test.kt:1:1:10:1 | Generic<? extends String> | test.kt:8:3:8:41 | setter | setter(java.lang.Void) | Void | void | test.kt:1:1:10:1 | Generic | test.kt:8:3:8:41 | setter |
75-
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:1:1:10:1 | equals | equals(java.lang.Object) | Object | boolean | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | equals |
76-
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:1:1:10:1 | hashCode | hashCode() | No parameters | int | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | hashCode |
77-
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:1:1:10:1 | toString | toString() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | toString |
7869
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:3:3:3:19 | getStored | getStored() | No parameters | Object | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | getStored |
7970
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:3:3:3:19 | setStored | setStored(java.lang.String) | String | void | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | setStored |
8071
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:5:3:5:46 | identity2 | identity2(java.lang.String) | String | Object | test.kt:1:1:10:1 | Generic | test.kt:5:3:5:46 | identity2 |
8172
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:6:3:6:35 | identity | identity(java.lang.String) | String | Object | test.kt:1:1:10:1 | Generic | test.kt:6:3:6:35 | identity |
8273
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:7:3:7:26 | getter | getter() | No parameters | Object | test.kt:1:1:10:1 | Generic | test.kt:7:3:7:26 | getter |
8374
| test.kt:1:1:10:1 | Generic<? super String> | test.kt:8:3:8:41 | setter | setter(java.lang.String) | String | void | test.kt:1:1:10:1 | Generic | test.kt:8:3:8:41 | setter |
84-
| test.kt:1:1:10:1 | Generic<String> | test.kt:1:1:10:1 | equals | equals(java.lang.Object) | Object | boolean | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | equals |
85-
| test.kt:1:1:10:1 | Generic<String> | test.kt:1:1:10:1 | hashCode | hashCode() | No parameters | int | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | hashCode |
86-
| test.kt:1:1:10:1 | Generic<String> | test.kt:1:1:10:1 | toString | toString() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:1:1:10:1 | toString |
8775
| test.kt:1:1:10:1 | Generic<String> | test.kt:3:3:3:19 | getStored | getStored() | No parameters | String | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | getStored |
8876
| test.kt:1:1:10:1 | Generic<String> | test.kt:3:3:3:19 | setStored | setStored(java.lang.String) | String | void | test.kt:1:1:10:1 | Generic | test.kt:3:3:3:19 | setStored |
8977
| test.kt:1:1:10:1 | Generic<String> | test.kt:5:3:5:46 | identity2 | identity2(java.lang.String) | String | String | test.kt:1:1:10:1 | Generic | test.kt:5:3:5:46 | identity2 |

0 commit comments

Comments
 (0)