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

Improve error message with invalid permits clauses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 25
    • tools
    • None
    • b24

      In the following code the error is not precise. The message reads "subclass B must extend sealed class". However, B is a "record" and does not "implement" the sealed "interface" B. The error can be improved by pointing to the accurate program elements by mentioning either "extends sealed class" or "implements sealed interface", alongside the correct kind, one of class/enum/record/interface.

          sealed interface A permits B {}
          record B() {}

      emits the following

      error: invalid permits clause
          sealed interface A permits B {}
                                     ^
        (subclass B must extend sealed class)
      1 error
      error: compilation failed

            abimpoudis Angelos Bimpoudis
            abimpoudis Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: