File tree 2 files changed +9
-14
lines changed
main/java/com/google/api/generator/engine/ast
test/java/com/google/api/generator/engine/ast
2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -67,9 +67,6 @@ public Builder setReturnExpr(Expr expr) {
67
67
68
68
public LambdaExpr build () {
69
69
LambdaExpr lambdaExpr = autoBuild ();
70
- Preconditions .checkState (
71
- !lambdaExpr .returnExpr ().expr ().type ().equals (TypeNode .VOID ),
72
- "Lambdas cannot return void-typed expressions." );
73
70
// Must be a declaration.
74
71
lambdaExpr .arguments ().stream ()
75
72
.forEach (
Original file line number Diff line number Diff line change @@ -85,17 +85,15 @@ public void validLambdaExpr_withBody() {
85
85
}
86
86
87
87
@ Test
88
- public void invalidLambdaExpr_returnsVoid () {
89
- assertThrows (
90
- IllegalStateException .class ,
91
- () ->
92
- LambdaExpr .builder ()
93
- .setReturnExpr (
94
- MethodInvocationExpr .builder ()
95
- .setMethodName ("foo" )
96
- .setReturnType (TypeNode .VOID )
97
- .build ())
98
- .build ());
88
+ public void validLambdaExpr_returnsVoid () {
89
+ LambdaExpr voidLambda = LambdaExpr .builder ()
90
+ .setReturnExpr (
91
+ MethodInvocationExpr .builder ()
92
+ .setMethodName ("foo" )
93
+ .setReturnType (TypeNode .VOID )
94
+ .build ())
95
+ .build ();
96
+ assertEquals (TypeNode .VOID , voidLambda .returnExpr ().type ());
99
97
}
100
98
101
99
@ Test
You can’t perform that action at this time.
0 commit comments