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

unexpected compiler error: cast, intersection types and sealed

XMLWordPrintable

    • b20

        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)

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

                Created:
                Updated:
                Resolved: