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

Skip to content

Commit a9711b8

Browse files
tamasvajkigfoo
authored andcommitted
Remove ExtensionMethodAccess to see extension method flows
1 parent 6fccbaa commit a9711b8

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,13 @@ private module ControlFlowGraphImpl {
550550
or
551551
index = 0 and result = this.(RValue).getQualifier() and not result instanceof TypeAccess
552552
or
553-
exists(Call e | e = this and not e instanceof ExtensionMethodAccess |
553+
exists(Call e | e = this | // and not e instanceof ExtensionMethodAccess |
554554
index = -1 and result = e.getQualifier() and not result instanceof TypeAccess
555555
or
556556
result = e.getArgument(index)
557557
)
558558
or
559+
/*
559560
exists(ExtensionMethodAccess e | e = this |
560561
// the actual qualifier of the expression method access
561562
index = -1 and result.(Expr).isNthChildOf(this, index) and not result instanceof TypeAccess
@@ -567,6 +568,7 @@ private module ControlFlowGraphImpl {
567568
result = e.getArgument(index - 1)
568569
)
569570
or
571+
*/
570572
exists(StringTemplateExpr e | e = this | result = e.getComponent(index))
571573
or
572574
index = 0 and result = this.(ClassExpr).getExpr()

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,6 +1987,7 @@ class MethodAccess extends Expr, Call, @methodaccess {
19871987
/**
19881988
* An invocation of a Kotlin `ExtensionMethod`.
19891989
*/
1990+
/*
19901991
class ExtensionMethodAccess extends MethodAccess {
19911992
ExtensionMethodAccess() { this.getMethod() instanceof ExtensionMethod }
19921993
@@ -1998,6 +1999,7 @@ class ExtensionMethodAccess extends MethodAccess {
19981999
19992000
override Expr getArgument(int index) { result = super.getArgument(index + 1) and index >= 0 }
20002001
}
2002+
*/
20012003

20022004
/** A type access is a (possibly qualified) reference to a type. */
20032005
class TypeAccess extends Expr, Annotatable, @typeaccess {

java/ql/lib/semmle/code/java/Variable.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,18 @@ class Parameter extends Element, @param, LocalScopeVariable {
111111
(
112112
exists(int idx |
113113
(
114-
idx = i and not call instanceof ExtensionMethodAccess
115-
or
116-
idx = i - 1 and call instanceof ExtensionMethodAccess
114+
idx = i //and not call instanceof ExtensionMethodAccess
115+
// or
116+
// idx = i - 1 and call instanceof ExtensionMethodAccess
117117
) and
118118
result = call.getArgument(idx)
119119
)
120+
/*
120121
or
121122
i = 0 and
122123
call instanceof ExtensionMethodAccess and
123124
result = call.getQualifier()
125+
*/
124126
) and
125127
call.getCallee().getSourceDeclaration().getAParameter() = this
126128
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
| test.kt:20:29:20:31 | new C(...) | test.kt:23:22:23:28 | self1(...) |
2+
| test.kt:20:29:20:31 | new C(...) | test.kt:26:22:26:28 | self2(...) |
23
| test.kt:20:29:20:31 | new C(...) | test.kt:29:18:29:29 | fn1(...) |
4+
| test.kt:20:29:20:31 | new C(...) | test.kt:32:18:32:29 | fn2(...) |
5+
| test.kt:20:29:20:31 | new C(...) | test.kt:35:18:35:31 | call1(...) |
6+
| test.kt:20:29:20:31 | new C(...) | test.kt:38:22:38:28 | call2(...) |

0 commit comments

Comments
 (0)