TypeVisitorAdapterTest.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:javalang-compiler 作者:
@Test
public void testTargetInferenceShouldFail() throws Exception {

    compile("import java.util.Collections; " + "import java.util.List; "
            + "public class A { public static <T> void processStringList(T[] args) {}}");
    SymbolType st = new SymbolType(getClassLoader().loadClass("A"));
    SymbolTable symTable = getSymbolTable();
    symTable.pushScope();
    symTable.pushSymbol("A", ReferenceType.TYPE, st, null);

    try {
        MethodCallExpr expr = (MethodCallExpr) ASTManager.parse(Expression.class,
                "A.processStringList(Collections.emptyList());");
        HashMap<String, Object> ctx = new HashMap<String, Object>();
        expressionAnalyzer.visit(expr, ctx);
        fail("should not be reached: type=" + expr.getSymbolData().getMethod());
    } catch (NoSuchExpressionTypeException e) {
        Assert.assertTrue(e.getMessage(), e.getMessage()
                .contains("Ops! The method call A.processStringList(Collections.emptyList()) is not resolved"));
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号