Skip to content

Commit ccb727e

Browse files
committed
C#: Test cases that shows that lambdas can be naturally (implicitly) typed and that the type is indistinguishable from the equivalent explicitly typed declaration.
1 parent a670330 commit ccb727e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lambdaDeclaration
2+
| Func<int, string> | Lambda.cs:7:27:7:28 | f1 | Lambda.cs:7:32:7:54 | (...) => ... |
3+
| Func<int, string> | Lambda.cs:8:13:8:14 | f2 | Lambda.cs:8:18:8:40 | (...) => ... |
4+
lambdaDeclarationNatural
5+
| Func<int, string> | Lambda.cs:8:13:8:14 | f2 | Lambda.cs:8:18:8:40 | (...) => ... |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import csharp
2+
3+
private predicate getLambda(
4+
LocalVariableDeclAndInitExpr e, string type, LocalVariable v, LambdaExpr lexp
5+
) {
6+
lexp = e.getRValue() and
7+
v = e.getTargetVariable() and
8+
type = e.getType().toStringWithTypes()
9+
}
10+
11+
query predicate lambdaDeclaration(string type, LocalVariable v, LambdaExpr lexp) {
12+
getLambda(_, type, v, lexp)
13+
}
14+
15+
query predicate lambdaDeclarationNatural(string type, LocalVariable v, LambdaExpr lexp) {
16+
exists(LocalVariableDeclAndInitExpr e | getLambda(e, type, v, lexp) and e.isImplicitlyTyped())
17+
}

0 commit comments

Comments
 (0)