paulk-asert opened a new pull request, #3011: URL: https://github.com/apache/groovy/pull/3011
…method is refused for final parameters and for final fields used inside their own class When static type checking resolves a compound assignment to a *Assign method the receiver is mutated in place, so a final target is not reassigned. Two checks refused it anyway. VariableScopeVisitor reported any assignment operator on a final parameter; it runs before type checking, so it now reports plain assignment only and leaves compound operators to the existing FinalVariableAnalyzer check in Verifier, which already skips a resolved *Assign target. ClassCompletionVerifier reported any assignment operator on a final field named directly or through this; it now skips assignments that carry COMPOUND_ASSIGN_TARGET. The classic code generation used by @TypeChecked still stored the result back into the left-hand side, which would update a final field outside its constructor (rejected by the JVM) and, for a final property reached from outside its class, failed with ReadOnlyPropertyException. Both the indy and the ScriptBytecodeAdapter paths now skip the store when the *Assign target is resolved, matching static compilation. As documented, the setter is then not invoked for a property target under @TypeChecked either. Dynamic code is unchanged apart from the message for a final parameter, which is now "The parameter [x] is declared final but is reassigned". -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
