use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class CompilerTestCase method createTypeCheck.
/**
* Returns a newly created TypeCheck.
*/
private static TypeCheck createTypeCheck(Compiler compiler) {
ReverseAbstractInterpreter rai = new SemanticReverseAbstractInterpreter(compiler.getTypeRegistry());
TypeCheck typeChecker = new TypeCheck(compiler, rai, compiler.getTypeRegistry());
compiler.setTypeCheckingHasRun(true);
return typeChecker;
}
use of com.google.javascript.jscomp.type.SemanticReverseAbstractInterpreter in project closure-compiler by google.
the class TypeCheckTest method testTypeCheckStandaloneAST.
@Test
public void testTypeCheckStandaloneAST() {
Node externs = IR.root();
Node firstScript = compiler.parseTestCode("function Foo() { }");
typeCheck(firstScript);
Node root = IR.root(externs, IR.root(firstScript.detach()));
TypedScopeCreator scopeCreator = new TypedScopeCreator(compiler);
TypedScope topScope = scopeCreator.createScope(root, null);
Node secondScript = compiler.parseTestCode("new Foo");
firstScript.replaceWith(secondScript);
new TypeCheck(compiler, new SemanticReverseAbstractInterpreter(registry), registry, topScope, scopeCreator).process(externs, secondScript.getParent());
assertThat(compiler.getWarningCount()).isEqualTo(1);
assertThat(compiler.getWarnings().get(0).getDescription()).isEqualTo("cannot instantiate non-constructor");
}
Aggregations