allow to infer expected type from cast expr (IDEA-97727)

This commit is contained in:
anna
2012-12-18 17:24:09 +01:00
parent 658b6230ed
commit 6db335d5ad
4 changed files with 34 additions and 0 deletions
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Test.java</file>
<line>5</line>
<description>Casting &lt;code&gt;getComponent(&quot;bar&quot;)&lt;/code&gt; to &lt;code&gt;Bar&lt;/code&gt; is redundant</description>
</problem>
<problem>
<file>Test.java</file>
<line>6</line>
<description>Casting &lt;code&gt;getComponent(&quot;bar&quot;)&lt;/code&gt; to &lt;code&gt;Bar&lt;/code&gt; is redundant</description>
</problem>
</problems>
@@ -0,0 +1,18 @@
class Test {
{
f((Bar) getComponent("bar"));
f1((Bar) getComponent("bar"));
Bar b = (Bar) getComponent("bar");
}
private <J extends Bar> void f(J j) {}
private <J> void f1(J j) {}
private <T> T getComponent(String name) {
return null;
}
static class Bar {}
}