Community
Participate
Working Groups
typeBinding = type.resolveBinding();
assertFalse("A Functional interface", typeBinding.isFunctionalInterface());
}
/**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=399793
*
* @throws JavaModelException
*/
public void test417017() throws JavaModelException {
this.workingCopy = getWorkingCopy("/Converter18/src/test417017/X.java",
true/* resolve */);
String contents = "package test417017;"
+ "interface I {\n"
+ " int foo(int x);\n"
+ "}\n"
+ "public class X {\n"
+ " void fun(int a) {\n"
+" I i1 = x1-> x1;\n"
+" I i2 = xxx-> {\n"
+" i1.foo(a);\n"
+" return xxx;\n"
+" };\n"
+" }\n"
+"}\n";
CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy);
TypeDeclaration typedeclaration = (TypeDeclaration) getASTNode(cu, 1);
MethodDeclaration methodDeclaration = typedeclaration.getMethods()[0];
VariableDeclarationFragment vdf= (VariableDeclarationFragment) ((VariableDeclarationStatement) methodDeclaration.getBody().statements().get(1)).fragments().get(0);
LambdaExpression lambda= (LambdaExpression) vdf.getInitializer();
List parameters = lambda.parameters();
assertTrue("Incorrect Number of parameters", parameters.size() == 1);
ITypeBinding[] parameterTypes= lambda.resolveMethodBinding().getParameterTypes();
// assertTrue("Incorrect Number of parameter type", parameterTypes.length == 1);// Wrong - see the next line.
assertTrue("Incorrect Number of parameter type", parameterTypes.length == 3); // Right - 2 synthetic (OuterLocalVariable) + 1 normal