[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-compiler-dev
Subject:    Re: Inference of recursive types
From:       Vicente-Arturo Romero-Zaldivar <vicente.romero () oracle ! com>
Date:       2014-02-24 21:27:36
Message-ID: 530BB948.60601 () oracle ! com
[Download RAW message or body]

Hi Liam,

Thanks for the bug report. I also think that this is a bug. I have filed 
this entry: https://bugs.openjdk.java.net/browse/JDK-8035713 to track it.

Vicente

On 21/02/14 21:09, Liam Miller-Cushon wrote:
> I was surprised that it starts working again with javac 8 source 8, 
> but I appreciate that it may not be a regression. Thanks for 
> investigating.
>
> Liam
>
>
> On Fri, Feb 21, 2014 at 1:02 PM, Vicente-Arturo Romero-Zaldivar 
> <vicente.romero@oracle.com <mailto:vicente.romero@oracle.com>> wrote:
>
>     On 21/02/14 19:31, Liam Miller-Cushon wrote:
>
>         +lambda-dev
>
>         Any thoughts on this?
>
>
>     Hi Liam,
>
>     I will look at this and get back to you. The fact that something
>     is working find in 7 and not in 8 source 7 doesn't imply that
>     there is a regression in the compiler. It can be a bug in 7 that
>     we don't have to reproduce in 8 just to keep the compatibility.
>     Every case is different and this could be a regression.
>
>     Thanks,
>     Vicente
>
>
>
>         This affects a significant amount of code, and the fact that
>         it only
>         appears when compiling java 7 with javac8 makes it look like a
>         regression.
>
>         The following is a less contrived example of code with
>         recursive types that
>         doesn't currently compile with javac8 -source 7 -target 7:
>
>         class Test {
>            <T extends Enum<T>> T getEnum() { return null; }
>            <U extends Enum<U>> void m() {
>              U e = getEnum();
>            }
>         }
>
>         $ javac -source 7 -target 7 Test.java
>         Test.java:4: error: incompatible types: inference variable T#1 has
>         incompatible upper bounds Enum<T#2>,U
>              U e = getEnum();
>                           ^
>            where T#1,T#2,U are type-variables:
>              T#1 extends Enum<T#1> declared in method <T#1>getEnum()
>              T#2 extends U
>              U extends Enum<U> declared in method <U>m()
>
>         On Fri, Feb 14, 2014 at 5:07 PM, Liam Miller-Cushon
>         <cushon@google.com <mailto:cushon@google.com>>wrote:
>
>             Hi -
>
>             Sorry if this has already been discussed, but I ran into a
>             difference in
>             behaviour between javac8 -source 7/-target 7 and both
>             javac7 and javac8
>             -source 8/-target 8.
>
>             The following program compiles with everything except
>             javac8 -source
>             7/-target 7.
>
>             Is this an intentional change? Having to make g's type
>             parameter explicit
>             feels like a regression.
>
>             ===
>             class Test {
>                static class One<T> {}
>                static class Two extends One<Two> {}
>
>                <T extends One<T>> T f(T a, String s) {
>                  T t = g(s);
>                  return t;
>                }
>                static <U extends One<U>> U g(String s) {
>                  throw new RuntimeException();
>                }
>             }
>             ===
>
>             Test.java:6: error: incompatible types: inference variable
>             U#1 has
>             incompatible upper bounds One<U#2>,T
>                  T t = g(s);
>                         ^
>                where U#1,U#2,T are type-variables:
>                  U#1 extends One<U#1> declared in method <U#1>g(String)
>                  U#2 extends T
>                  T extends One<T> declared in method <T>f(T,String)
>
>
>


[Attachment #3 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Liam,<br>
      <br>
      Thanks for the bug report. I also think that this is a bug. I have
      filed this entry: <a class="moz-txt-link-freetext" \
href="https://bugs.openjdk.java.net/browse/JDK-8035713">https://bugs.openjdk.java.net/browse/JDK-8035713</a>
  to track it.<br>
      <br>
      Vicente<br>
      <br>
      On 21/02/14 21:09, Liam Miller-Cushon wrote:<br>
    </div>
    <blockquote
cite="mid:CAL4Qsgu2o5EvyOP0ajkLnDZC4r1CGrEYu2JOH-kAgquuMJQLOQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">I was surprised that it starts working again with
        javac 8 source 8, but I appreciate that it may not be a
        regression. Thanks for investigating.
        <div>
          <div><br>
          </div>
          <div>Liam</div>
        </div>
      </div>
      <div class="gmail_extra">
        <br>
        <br>
        <div class="gmail_quote">On Fri, Feb 21, 2014 at 1:02 PM,
          Vicente-Arturo Romero-Zaldivar <span dir="ltr">&lt;<a
              moz-do-not-send="true"
              href="mailto:vicente.romero@oracle.com" \
target="_blank">vicente.romero@oracle.com</a>&gt;</span>  wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div class="">On 21/02/14 19:31, Liam Miller-Cushon wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                +lambda-dev<br>
                <br>
                Any thoughts on this?<br>
              </blockquote>
              <br>
            </div>
            Hi Liam,<br>
            <br>
            I will look at this and get back to you. The fact that
            something is working find in 7 and not in 8 source 7 doesn't
            imply that there is a regression in the compiler. It can be
            a bug in 7 that we don't have to reproduce in 8 just to keep
            the compatibility. Every case is different and this could be
            a regression.<br>
            <br>
            Thanks,<br>
            Vicente
            <div class="HOEnZb">
              <div class="h5"><br>
                <br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <br>
                  This affects a significant amount of code, and the
                  fact that it only<br>
                  appears when compiling java 7 with javac8 makes it
                  look like a regression.<br>
                  <br>
                  The following is a less contrived example of code with
                  recursive types that<br>
                  doesn't currently compile with javac8 -source 7
                  -target 7:<br>
                  <br>
                  class Test {<br>
                     &lt;T extends Enum&lt;T&gt;&gt; T getEnum() {
                  return null; }<br>
                     &lt;U extends Enum&lt;U&gt;&gt; void m() {<br>
                       U e = getEnum();<br>
                     }<br>
                  }<br>
                  <br>
                  $ javac -source 7 -target 7 Test.java<br>
                  Test.java:4: error: incompatible types: inference
                  variable T#1 has<br>
                  incompatible upper bounds Enum&lt;T#2&gt;,U<br>
                       U e = getEnum();<br>
                                    ^<br>
                     where T#1,T#2,U are type-variables:<br>
                       T#1 extends Enum&lt;T#1&gt; declared in method
                  &lt;T#1&gt;getEnum()<br>
                       T#2 extends U<br>
                       U extends Enum&lt;U&gt; declared in method
                  &lt;U&gt;m()<br>
                  <br>
                  On Fri, Feb 14, 2014 at 5:07 PM, Liam Miller-Cushon
                  &lt;<a moz-do-not-send="true"
                    href="mailto:cushon@google.com" \
target="_blank">cushon@google.com</a>&gt;wrote:<br>  <br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    Hi -<br>
                    <br>
                    Sorry if this has already been discussed, but I ran
                    into a difference in<br>
                    behaviour between javac8 -source 7/-target 7 and
                    both javac7 and javac8<br>
                    -source 8/-target 8.<br>
                    <br>
                    The following program compiles with everything
                    except javac8 -source<br>
                    7/-target 7.<br>
                    <br>
                    Is this an intentional change? Having to make g's
                    type parameter explicit<br>
                    feels like a regression.<br>
                    <br>
                    ===<br>
                    class Test {<br>
                       static class One&lt;T&gt; {}<br>
                       static class Two extends One&lt;Two&gt; {}<br>
                    <br>
                       &lt;T extends One&lt;T&gt;&gt; T f(T a, String s)
                    {<br>
                         T t = g(s);<br>
                         return t;<br>
                       }<br>
                       static &lt;U extends One&lt;U&gt;&gt; U g(String
                    s) {<br>
                         throw new RuntimeException();<br>
                       }<br>
                    }<br>
                    ===<br>
                    <br>
                    Test.java:6: error: incompatible types: inference
                    variable U#1 has<br>
                    incompatible upper bounds One&lt;U#2&gt;,T<br>
                         T t = g(s);<br>
                                ^<br>
                       where U#1,U#2,T are type-variables:<br>
                         U#1 extends One&lt;U#1&gt; declared in method
                    &lt;U#1&gt;g(String)<br>
                         U#2 extends T<br>
                         T extends One&lt;T&gt; declared in method
                    &lt;T&gt;f(T,String)<br>
                    <br>
                  </blockquote>
                </blockquote>
                <br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic