void () { Optional<String> optional = Optional.empty(); final boolean present = optional.isPresent(); // optional = Optional.empty(); if (present) { // do not warn here as the branch is unreachable final String string = optional.get(); System.out.println(string); } }