Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8275302

unexpected compiler error: cast, intersection types and sealed

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b20

      Backports

        Description

        The compiler is currently rejecting this code:

        public class X {
            abstract class Base {}
            interface Marker {}
            sealed class B extends Base {}
            final class C extends B implements Marker {}
            private <T extends Base & Marker> void test(T obj) {
                B b = (B) obj; //error - cannot convert T to B
            }
        }

        this seems like a bug in the current implementation of the sealed classes spec (reported offline by Jan)

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                vromero Vicente Arturo Romero Zaldivar
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: