@Test
public void testLambdaExpressionsWithExplicitArgs() throws Exception {
if (SourceVersion.latestSupported().ordinal() >= 8) {
String BCode = "public interface B { public int execute(int c); } ";
compile("public class A{ public void run(B b){} " + BCode + "}");
SymbolType st = new SymbolType(getClassLoader().loadClass("A"));
SymbolTable symTable = getSymbolTable();
symTable.pushScope();
symTable.pushSymbol("a", ReferenceType.TYPE, st, null);
MethodCallExpr expr = (MethodCallExpr) ASTManager.parse(Expression.class, "a.run((int d)->d+1)");
HashMap<String, Object> ctx = new HashMap<String, Object>();
expressionAnalyzer.visit(expr, ctx);
SymbolType type = (SymbolType) expr.getSymbolData();
Assert.assertNotNull(type);
Assert.assertEquals("A$B", type.getMethod().getParameterTypes()[0].getName());
}
}
TypeVisitorAdapterTest.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:javalang-compiler
作者:
评论列表
文章目录