8.4.1: Error for receiver parameter of an inner class in a static context

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 10
    • Affects Version/s: 8, 9
    • Component/s: specification

      Some inner classes can occur in static contexts (8.4.1)—e.g., a local class declared in a static method. But these inner classes have no immediately enclosing instance, so shouldn't have a receiver parameter.

      Proposed rule:

      A receiver parameter may appear only in the FormalParameterList of an instance method or ~~an inner class's constructor~~ **a constructor of an inner class, where the inner class is not declared in a static context**; otherwise, a compile-time error occurs.

      Or, if that's too much of a mouthful:

      A receiver parameter may appear only in the FormalParameterList of an instance method or an inner class's constructor; otherwise, a compile-time error occurs.

      **If a receiver parameter appears in the FormalParameterList of an inner class's constructor, but that class is declared in a static context, a compile-time error occurs.**

            Assignee:
            Alex Buckley
            Reporter:
            Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: