Java Generics: Why does an explicit cast cause a compiler error, but variable assignment does not
<p>This block compiles properly:</p>

<pre><code>ArrayList&lt;Baz&gt; list = savedInstanceState.getParcelableArrayList("foo");
bar(list);
</code></pre>

<p>But this block errors stating that <code>ArrayList&lt;Parcelable&gt;</code> can not be cast to <code>ArrayList&lt;Baz&gt;</code>:</p>

<pre><code>bar((ArrayList&lt;Baz&gt;)savedInstanceState.getParcelableArrayList("foo"))
</code></pre>

<p>Where bar is of the form:</p>

<pre><code>private void bar(ArrayList&lt;Baz&gt; food) {
}
</code></pre>

<p>And <code>Baz</code> is a class that implements the <code>Parcelable</code> interface</p>

<p>Is there a way that the direct cast can be done rather than having to perform an implicit cast and create an unnecessary variable?</p>
