@Test
public void testDiamond() throws Exception {
if (SourceVersion.latestSupported().ordinal() >= 7) {
compile("import java.util.List; import java.util.LinkedList; public class A{ List<Integer> bar = new LinkedList<>(); }");
SymbolTable symTable = getSymbolTable();
symTable.pushScope();
SymbolType st = new SymbolType(getClassLoader().loadClass("A"));
symTable.pushSymbol("a", ReferenceType.VARIABLE, st, null);
FieldAccessExpr expr = (FieldAccessExpr) ASTManager.parse(Expression.class, "a.bar");
HashMap<String, Object> ctx = new HashMap<String, Object>();
expressionAnalyzer.visit(expr, ctx);
SymbolType type = (SymbolType) expr.getSymbolData();
Assert.assertNotNull(type);
Assert.assertEquals("java.util.List", type.getName());
Assert.assertNotNull(type.getParameterizedTypes());
Assert.assertEquals("java.lang.Integer", type.getParameterizedTypes().get(0).getName());
}
}
TypeVisitorAdapterTest.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:javalang-compiler
作者:
评论列表
文章目录