-
Enhancement
-
Resolution: Fixed
-
P4
-
18
Many sections in Ch.8 have a sentence that says "The scope and shadowing of a XYZ declaration is specified in §6.3 and §6.4.1." However, section 8.10.1 Record Components does not. Why? Because a record component is not a declaration. Rather, a record component _corresponds_ to two members of the record class: a private field declared implicitly, and a public accessor method declared explicitly or implicitly. Section 6.1 Declarations is careful to speak about the field declaration and method declaration, and never mentions a "record component declaration".
Since a record component is not a declaration, it has no scope of its own. The scope of the record component's corresponding field and method are specified as usual by 6.3. Namely, they can be referenced by simple name in the body of the record declaration, but not in its header (the RecordComponentList).
It would be proper for 8.10.3 to say:
"The scope and shadowing of the component field and the accessor method are specified in §6.3 and §6.4.1. (The record component to which they correspond is not a declaration, so has no scope of its own.)"
It would also be proper for 8.10.1 to speak more carefully about the record component, to avoid implying it is a declaration (which would mean having a scope):
- The rules concerning annotation modifiers for a record component declaration ...
- Annotations on a record component declaration ...
- It is a compile-time error for a record declaration to declare a record component with the name ...
- It is a compile-time error for a record declaration to declare two record components with the same name.
Since a record component is not a declaration, it has no scope of its own. The scope of the record component's corresponding field and method are specified as usual by 6.3. Namely, they can be referenced by simple name in the body of the record declaration, but not in its header (the RecordComponentList).
It would be proper for 8.10.3 to say:
"The scope and shadowing of the component field and the accessor method are specified in §6.3 and §6.4.1. (The record component to which they correspond is not a declaration, so has no scope of its own.)"
It would also be proper for 8.10.1 to speak more carefully about the record component, to avoid implying it is a declaration (which would mean having a scope):
- The rules concerning annotation modifiers for a record component declaration ...
- Annotations on a record component declaration ...
- It is a compile-time error for a record declaration to declare a record component with the name ...
- It is a compile-time error for a record declaration to declare two record components with the same name.
- relates to
-
JDK-8284011 6.6.1: Clarify that a private member class can be used in a permits clause and as a record component
-
- Resolved
-
-
JDK-8282916 6.3: Clarify that a nested declaration's scope includes component list of enclosing record class
-
- Resolved
-