title: Intellij is giving strange error. Java Generics issue
body: <p>I want to produce an object from a string, I also want that produced object to be of type IObjectImpl that extends IObject.</p>
  
  <p>So, I have a factory class method that takes a string and an interface class(say IObjectImpl.class that extends IObject, which is mandatory). That method should automatically detect that the object produced from string(using reflection) type is IObject and cast it to IObjectImpl.</p>
  
  <p>I have written the following code for testing. But, Intellij does not show error and at the same time while I run the main method, I get the error shown at the end.  </p>
  
  <pre><code>public &lt;T extends IObject, E extends T&gt; E getInstanceOfType(String clazz, Class type) {
      try {
          System.out.println("Type got is " + type);
          return null;
      } catch (Exception exception) {
          throw new ObjectInstantiationException(String.format("Could not create the "
                  + "instance of type %s", clazz), exception);
      }
  }
  
  public static void main(String[] args) {
      new Factory().getInstanceOfType("Some class", IObjectImpl.class);
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>    Error:(67, 49) java: ..path\Factory.java:67: incompatible types; inferred type argument(s) com.myCompany.IObject,java.lang.Object do not conform to bounds of type variable(s) T,E
  found   : &lt;T,E&gt;E
  required: java.lang.Object
  </code></pre>
  
  <p>As far as checking type, I just know about eClass.isAssignableFrom(tClass) approach.</p>
  
  <p>My final goal is that I should be able to call the methods defined in <code>IObjectImpl</code> without any cast. How can I do it using Java 1.6?</p>