/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import java.util.*; class Iterators { void hasNextOk(List xs) { Iterator i = xs.iterator(); if (i.hasNext()) i.next(); } void hasNextBad(List xs) { Iterator i = xs.iterator(); i.next(); } /** Check that errors don't bubble up the call chain. */ void hasNextNotTooBadOk(List xs) { hasNextBad(xs); } void hasNextInterproceduralBad(List xs) { getSingleElementOk(xs.iterator()); } void hasNextInterproceduralOk(List xs) { Iterator i = xs.iterator(); if (i.hasNext()) { getSingleElementOk(i); } } void getSingleElementOk(Iterator i) { i.next(); } }