paulk-asert commented on code in PR #2645:
URL: https://github.com/apache/groovy/pull/2645#discussion_r3669695377


##########
src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java:
##########
@@ -424,6 +434,20 @@ public void setLogClassgenStackTraceMaxDepth(int 
logClassgenStackTraceMaxDepth)
      */
     private Set<String> scriptExtensions = new LinkedHashSet<>();
 
+    /**
+     * Consumer vetoes for {@link groovy.transform.stc.ClassTag @ClassTag} 
preemption under static
+     * compilation (GROOVY-12115). Preemption is declared by the API author
+     * ({@code @ClassTag(preempt=true)}) and contained to the declaring class; 
this set lets the
+     * consuming build veto it anyway. Entries use the same selector forms as
+     * {@code groovy.extension.disable}: a bare method name ({@code 
withDefault}) vetoes all
+     * overloads of that name, a signature form ({@code 
withDefault(Map,Class,Closure)}, simple or
+     * fully-qualified type names) vetoes the exact overload, and {@code *} 
vetoes all preemption.
+     * Additive injection (supplying an otherwise-mandatory token, such as for 
{@code asChecked})
+     * is never gated by this set. Seeded from the {@code 
groovy.classtag.preemption.disable}
+     * system property; empty (the default) honours declared intent. Never 
null.
+     */
+    private Set<String> classTagPreemptionDisabled = 
splitRespectingParens(getSystemPropertySafe("groovy.classtag.preemption.disable"));

Review Comment:
   It will be rare. It is about code that runs today, that might break, e.g.:
   
   @groovy.transform.CompileStatic
   static void main() {
       Map<String, Integer> counts = [:]
       def m = counts.withDefault { 0 }
       assert m.get('a') == 0
       assert m.get(42) == 0 // was: success, now: ClassCastException
   }
   
   It only runs today because MapWithDefault has unsound code that grows the 
Map with the default when we call get. This is what GROOVY-11807 was pointing 
out, `get` takes Object which looks safe but has the side effect. The compiler 
config/flag is all about, I have code that runs today and I don't want to touch 
it and I want it to still run. Eventually, I might be able to change that code 
to not rely on the unsoundness and then I can remove the config/flag.



##########
src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java:
##########
@@ -424,6 +434,20 @@ public void setLogClassgenStackTraceMaxDepth(int 
logClassgenStackTraceMaxDepth)
      */
     private Set<String> scriptExtensions = new LinkedHashSet<>();
 
+    /**
+     * Consumer vetoes for {@link groovy.transform.stc.ClassTag @ClassTag} 
preemption under static
+     * compilation (GROOVY-12115). Preemption is declared by the API author
+     * ({@code @ClassTag(preempt=true)}) and contained to the declaring class; 
this set lets the
+     * consuming build veto it anyway. Entries use the same selector forms as
+     * {@code groovy.extension.disable}: a bare method name ({@code 
withDefault}) vetoes all
+     * overloads of that name, a signature form ({@code 
withDefault(Map,Class,Closure)}, simple or
+     * fully-qualified type names) vetoes the exact overload, and {@code *} 
vetoes all preemption.
+     * Additive injection (supplying an otherwise-mandatory token, such as for 
{@code asChecked})
+     * is never gated by this set. Seeded from the {@code 
groovy.classtag.preemption.disable}
+     * system property; empty (the default) honours declared intent. Never 
null.
+     */
+    private Set<String> classTagPreemptionDisabled = 
splitRespectingParens(getSystemPropertySafe("groovy.classtag.preemption.disable"));

Review Comment:
   It will be rare. It is about code that runs today, that might break, e.g.:
   
   ```
   @groovy.transform.CompileStatic
   static void main() {
       Map<String, Integer> counts = [:]
       def m = counts.withDefault { 0 }
       assert m.get('a') == 0
       assert m.get(42) == 0 // was: success, now: ClassCastException
   }
   ```
   
   It only runs today because MapWithDefault has unsound code that grows the 
Map with the default when we call get. This is what GROOVY-11807 was pointing 
out, `get` takes Object which looks safe but has the side effect. The compiler 
config/flag is all about, I have code that runs today and I don't want to touch 
it and I want it to still run. Eventually, I might be able to change that code 
to not rely on the unsoundness and then I can remove the config/flag.



-- 
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]

Reply via email to