Skip to content

Commit 25019db

Browse files
committed
C#: Add support QL library support for lambda explicit return types.
1 parent eb8c226 commit 25019db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

csharp/ql/lib/semmle/code/csharp/exprs/Creation.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import Expr
66
import semmle.code.csharp.Callable
77
private import semmle.code.csharp.frameworks.system.linq.Expressions
8+
private import semmle.code.csharp.TypeRef
89

910
/**
1011
* Either an object initializer (`ObjectInitializer`) or a collection
@@ -434,6 +435,12 @@ class AnonymousFunctionExpr extends Expr, Callable, Modifiable, @anonymous_funct
434435
* A lambda expression, for example `(int x) => x + 1`.
435436
*/
436437
class LambdaExpr extends AnonymousFunctionExpr, @lambda_expr {
438+
/* Holds if this lambda expression has explicit return type. */
439+
predicate hasExplicitReturnType() { lambda_expr_return_type(this, _) }
440+
441+
/* Gets the explicit return type of this lambda expression, if any. */
442+
Type getExplicitReturnType() { lambda_expr_return_type(this, getTypeRef(result)) }
443+
437444
override string toString() { result = "(...) => ..." }
438445

439446
override string getAPrimaryQlClass() { result = "LambdaExpr" }

0 commit comments

Comments
 (0)