<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 27, 2020 at 5:38 AM Martin Kouba &lt;<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>&gt; wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think that you&#39;re right. Foo&lt;E&gt; is basically Foo&lt;E extends Object&gt; and <br>
according to the rules String is assignable to Object.</blockquote><div><br></div><div>Just to be clear, this test (that I added temporarily to <font face="monospace">CovariantTypesTest</font> and ran just to make sure) fails (as I&#39;d expect):</div><div><font face="monospace"><br></font></div><div><font face="monospace">@Test<br>public &lt;E&gt; void testFooStringAssignableFromFooE() {<br>    Type a = new TypeLiteral&lt;Foo&lt;String&gt;&gt;() {<br>    }.getType();<br>    Type b = new TypeLiteral&lt;Foo&lt;E&gt;&gt;() {<br>    }.getType();</font></div><div><font face="monospace">    assertTrue(CovariantTypes.isAssignableFrom(a, b)); // kaboom<br>}</font><br></div><div><br></div><div>But this test (the one under discussion) in <font face="monospace">BeanTypeAssignabilityRules</font> succeeds (obviously or Weld&#39;s test suite would be broken):</div><div><br></div><div><font face="monospace">@Test<br>public &lt;E&gt; void testStringFooMatchesVariableFoo() throws Exception {<br>    Type stringFooType = new TypeLiteral&lt;Foo&lt;String&gt;&gt;() {<br>    }.getType();<br>    Type variableFooType = new TypeLiteral&lt;Foo&lt;E&gt;&gt;() {<br>    }.getType();<br>    Assert.assertTrue(&quot;Foo&lt;String&gt; should match Foo&lt;E&gt;&quot;, getRules().matches(stringFooType, variableFooType));<br>}</font><br></div><div><br></div><div>So the rules CDI uses to do type matching (represented by <font face="monospace">BeanTypeAssignabilityRules</font>) are deliberately different from those used by JLS (represented by <font face="monospace">CovariantTypes</font>), right?</div><div><br></div><div>Best,</div><div>Laird</div></div></div>