title: A warning is shown when Optional.isPresent and Optional.get are called "on different" levels?
body: <p>In the following code snippet, I have <code>Foo</code> class with a method that always returns the same instance of <code>Optional</code>. And then I have another <code>OneMoreClass</code> class that uses <code>Foo</code> class. </p>
  
  <p>You can see from the source code that it's safe to call <code>get()</code> method in <code>method1</code> because it is always checked in the <code>method2</code>. </p>
  
  <p>The problem that IntelliJ IDEA still shows a warning (you can just copy this snippet to IDEA and you will see the issue).</p>
  
  <pre><code>public class Example {
  
      public static class Foo {
  
          private final Optional&lt;String&gt; value = Optional.empty();
  
          public Optional&lt;String&gt; bar() {
              return value;
          }
      }
  
      public static class OneMoreClass {
          void method1(final Foo foo) {
              method2(foo);
              System.out.println(foo.bar().get()); // here the warning is shown in IntelliJ IDEA: 
                                                   // "Optional.get()" without "isPresent()" check
          }
  
          void method2(final Foo foo) {
              if (!foo.bar().isPresent()) {
                  throw new IllegalArgumentException("No value");
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>The question is:</strong> how can I fix the warning? Is there any trick to avoid this warning?</p>