mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
switch tests on new inference
(cherry picked from commit d2cbf3f2833104c3a0381059b0d6ef8ac0b3c94c)
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
class CyclicInference {
|
||||
|
||||
interface Execute {
|
||||
void execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lambda wrapper for expression-like lambdas
|
||||
*
|
||||
* @param lambda
|
||||
* @param <I> interface which lambda class implements (derived by compiler via type inference)
|
||||
* @param <T> lambda class having function code to be executed
|
||||
* @return I interface implemented by lambda
|
||||
*/
|
||||
private static <I, T extends I> I lambdaWrapper(final T lambda) {
|
||||
return (I)lambda;
|
||||
}
|
||||
|
||||
/**
|
||||
* How expression-like lambdas returning void can be wrapped
|
||||
*/
|
||||
public void lambdaWithOneExpressionReturningVoid() {
|
||||
Execute sayHello = lambdaWrapper(() -> System.out.println("Hello"));
|
||||
sayHello.execute();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CyclicInference lam = new CyclicInference();
|
||||
lam.lambdaWithOneExpressionReturningVoid();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user