typeRegistry.resolveTypesInScope(scope);
assertFalse(functionType.getReturnType().isUnknownType());
}
public void testTypeResolutionModes() {
SimpleErrorReporter reporter = new SimpleErrorReporter();
JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(reporter);
lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);
JSTypeRegistry lazyNameRegistry = new JSTypeRegistry(reporter);
lazyNameRegistry.setResolveMode(ResolveMode.LAZY_NAMES);
JSTypeRegistry immediateRegistry = new JSTypeRegistry(reporter);
immediateRegistry.setResolveMode(ResolveMode.IMMEDIATE);
Node expr = new Node(Token.QMARK, Node.newString("foo"));
StaticScope<JSType> empty = MapBasedScope.emptyScope();
JSType type = lazyExprRegistry.createFromTypeNodes(
expr, "source.js", empty);
assertTrue(type instanceof UnresolvedTypeExpression);
assertTrue(type.isUnknownType());
assertEquals("?", type.toString());
assertNull("Unexpected warnings: " + reporter.warnings(),
reporter.warnings());
type = lazyNameRegistry.createFromTypeNodes(
expr, "source.js", empty);
assertTrue(type instanceof UnionType);
assertTrue(type.isUnknownType());
assertEquals("(foo|null)", type.toString());
assertNull("Unexpected warnings: " + reporter.warnings(),
reporter.warnings());
type = immediateRegistry.createFromTypeNodes(
expr, "source.js", empty);
assertTrue(type instanceof UnknownType);
assertEquals("Expected warnings", 1, reporter.warnings().size());
}