mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Specify lambda method for big arity lambdas
This commit is contained in:
@@ -1677,8 +1677,6 @@ open class KotlinFileExtractor(
|
||||
|
||||
if (types.size > BuiltInFunctionArity.BIG_ARITY) {
|
||||
implementFunctionNInvoke(e.function, ids, locId, parameters)
|
||||
|
||||
// todo: which method should be returned in `LambdaExpr.asMethod()`?
|
||||
}
|
||||
|
||||
val exprParent = parent.expr(e, callable)
|
||||
|
||||
@@ -1256,7 +1256,21 @@ class LambdaExpr extends FunctionalExpr, @lambdaexpr {
|
||||
* Gets the implicit method corresponding to this lambda expression.
|
||||
* The parameters of the lambda expression are the parameters of this method.
|
||||
*/
|
||||
override Method asMethod() { result = this.getAnonymousClass().getAMethod() }
|
||||
override Method asMethod() {
|
||||
not isKotlinFunctionN() and
|
||||
result = this.getAnonymousClass().getAMethod()
|
||||
or
|
||||
isKotlinFunctionN() and
|
||||
result = this.getAnonymousClass().getAMethod() and
|
||||
result.getNumberOfParameters() = 1
|
||||
}
|
||||
|
||||
predicate isKotlinFunctionN() {
|
||||
exists(RefType r |
|
||||
this.getAnonymousClass().extendsOrImplements(r) and
|
||||
r.getSourceDeclaration().hasQualifiedName("kotlin.jvm.functions", "FunctionN")
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if the body of this lambda is an expression. */
|
||||
predicate hasExprBody() { lambdaKind(this, 0) }
|
||||
@@ -2202,9 +2216,7 @@ class WhenBranch extends Top, @whenbranch {
|
||||
predicate isElseBranch() { when_branch_else(this) }
|
||||
|
||||
/** Gets the `when` expression this is a branch of. */
|
||||
WhenExpr getWhenExpr() {
|
||||
this = result.getBranch(_)
|
||||
}
|
||||
WhenExpr getWhenExpr() { this = result.getBranch(_) }
|
||||
|
||||
override string toString() { result = "... -> ..." }
|
||||
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
| funcExprs.kt:25:28:25:51 | ...->... | stmt body | funcExprs.kt:25:28:25:51 | invoke | invoke(int) | funcExprs.kt:25:28:25:51 | new Function1<Integer,Function1<Integer,Double>>(...) { ... } |
|
||||
| funcExprs.kt:25:37:25:47 | ...->... | stmt body | funcExprs.kt:25:37:25:47 | invoke | invoke(int) | funcExprs.kt:25:37:25:47 | new Function1<Integer,Double>(...) { ... } |
|
||||
| funcExprs.kt:27:29:27:112 | ...->... | stmt body | funcExprs.kt:27:29:27:112 | invoke | invoke(int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int) | funcExprs.kt:27:29:27:112 | new Function22<Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Integer,Unit>(...) { ... } |
|
||||
| funcExprs.kt:28:29:28:117 | ...->... | stmt body | funcExprs.kt:28:29:28:117 | invoke | invoke(int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int) | funcExprs.kt:28:29:28:117 | new FunctionN<String>(...) { ... } |
|
||||
| funcExprs.kt:28:29:28:117 | ...->... | stmt body | funcExprs.kt:28:29:28:117 | invoke | invoke(java.lang.Object[]) | funcExprs.kt:28:29:28:117 | new FunctionN<String>(...) { ... } |
|
||||
|
||||
Reference in New Issue
Block a user