Paul King created GROOVY-11910:
----------------------------------

             Summary: Add ModifiesChecker type checking extension to verify 
@Modifies frame conditions
                 Key: GROOVY-11910
                 URL: https://issues.apache.org/jira/browse/GROOVY-11910
             Project: Groovy
          Issue Type: New Feature
            Reporter: Paul King


Add an opt-in ModifiesChecker type checking extension in groovy-typecheckers 
that verifies method bodies comply with their @Modifies frame condition 
declarations (GROOVY-11909). Enabled  
  via @TypeChecked(extensions = 'groovy.typecheckers.ModifiesChecker').         
                                                                                
                                          
                                                                                
                                                                                
                                          
  The checker validates that:                                                   
                                                                                
                                          
  - Direct field assignments only target fields listed in @Modifies             
                                                                                
                                          
  - Calls to methods on this have compatible @Modifies frames or are @Pure      
                                                                                
                                          
  - Calls on parameters/variables not in @Modifies use only non-mutating methods
                                                                                
                                                                                
                                          
  Non-mutating calls are determined by a layered approach: immutable receiver 
type detection (reusing ImmutablePropertyUtils), @Pure annotation, and a 
curated whitelist of safe method names (size, get, 
  contains, toString, etc.). Unknown calls produce warnings rather than errors 
to support incremental adoption.                                                
                                           
                                                                                
                                                                                
                                          
  No hard dependency on groovy-contracts — the checker communicates via node 
metadata set by ModifiesASTTransformation.                                      
                                             
                                                            



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to