(groovy-dev-site) branch asf-site updated: 2024/05/09 22:40:51: Generated dev website from groovy-website@01910a5

2024-05-09 Thread git-site-role
This is an automated email from the ASF dual-hosted git repository.

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-dev-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
 new 5c1e8e4  2024/05/09 22:40:51: Generated dev website from 
groovy-website@01910a5
5c1e8e4 is described below

commit 5c1e8e49f3695dcffeef550b13bef892cbbccdf1
Author: jenkins 
AuthorDate: Thu May 9 22:40:51 2024 +

2024/05/09 22:40:51: Generated dev website from groovy-website@01910a5
---
 blog/adventures-with-groovyfx.html   |  2 +-
 blog/classifying-iris-flowers-with-deep.html |  2 +-
 blog/comparators-and-sorting-in-groovy.html  |  2 +-
 blog/deck-of-cards-with-groovy.html  |  2 +-
 blog/deep-learning-and-eclipse-collections.html  |  2 +-
 blog/detecting-objects-with-groovy-the.html  |  2 +-
 blog/feed.atom   | 12 ++--
 blog/fruity-eclipse-collections.html |  2 +-
 blog/fun-with-obfuscated-groovy.html |  2 +-
 blog/gmavenplus-1-6-2-released.html  |  2 +-
 blog/gpars-meets-virtual-threads.html|  4 ++--
 blog/groovy-2-4-16-released.html |  2 +-
 blog/groovy-2-4-16-windows.html  |  2 +-
 blog/groovy-2-4-17-released.html |  2 +-
 blog/groovy-2-5-0-released.html  |  2 +-
 blog/groovy-2-5-1-released.html  |  2 +-
 blog/groovy-2-5-2-released.html  |  2 +-
 blog/groovy-2-5-2-windows.html   |  2 +-
 blog/groovy-2-5-3-released.html  |  2 +-
 blog/groovy-2-5-3-windows.html   |  2 +-
 blog/groovy-2-5-4-released.html  |  2 +-
 blog/groovy-2-5-4-windows.html   |  2 +-
 blog/groovy-2-5-5-released.html  |  2 +-
 blog/groovy-2-5-5-windows.html   |  2 +-
 blog/groovy-2-5-6-released.html  |  2 +-
 blog/groovy-2-5-7-and.html   |  2 +-
 blog/groovy-2-5-7-released.html  |  2 +-
 blog/groovy-2-5-clibuilder-renewal.html  |  2 +-
 blog/groovy-3-0-0-alpha.html |  2 +-
 blog/groovy-3-0-0-alpha1.html|  2 +-
 blog/groovy-3-0-0-beta.html  |  2 +-
 blog/groovy-3-0-0-beta1.html |  2 +-
 blog/groovy-3-0-0-beta2.html |  2 +-
 blog/groovy-4-0-3-released.html  |  2 +-
 blog/groovy-dauphine.html|  2 +-
 blog/groovy-haiku-processing.html|  2 +-
 blog/groovy-list-processing-cheat-sheet.html |  2 +-
 blog/groovy-null-processing.html |  2 +-
 blog/groovy-record-performance.html  |  2 +-
 blog/groovy-records.html |  2 +-
 blog/groovy-release-train-4-0.html   |  2 +-
 blog/groovy-sequenced-collections.html   |  2 +-
 blog/helloworldemoji.html|  2 +-
 blog/index.html  |  4 ++--
 blog/lego-bricks-with-groovy.html|  2 +-
 blog/matrix-calculations-with-groovy-apache.html |  2 +-
 blog/parsing-json-with-groovy.html   |  2 +-
 blog/reading-and-writing-csv-files.html  |  2 +-
 blog/seasons-greetings-emoji.html|  2 +-
 blog/set-operations-with-groovy.html |  2 +-
 blog/using-groovy-with-apache-wayang.html|  2 +-
 blog/whiskey-clustering-with-groovy-and.html |  2 +-
 blog/wordle-checker.html |  2 +-
 blog/working-with-sql-databases-with.html|  2 +-
 blog/zipping-collections-with-groovy.html|  2 +-
 55 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/blog/adventures-with-groovyfx.html 
b/blog/adventures-with-groovyfx.html
index a599efe..f302b18 100644
--- a/blog/adventures-with-groovyfx.html
+++ b/blog/adventures-with-groovyfx.html
@@ -53,7 +53,7 @@
 
 
 
-Blog indexAdventures with GroovyFXFurther 
informationRelated postsBlog indexAdventures with GroovyFXFurther 
informationRelated posts
 
 This blog looks at a http://groovyfx.org/";>GroovyFX version of 
a https://donraab.medium.com/my-weird-and-wonderful-first-adventures-with-javafx-6efe3b1923c8";>ToDo
 application originally written in JavaFX.
diff --git a/blog/classifying-iris-flowers-with-deep.html 
b/blog/classifying-iris-flowers-with-deep.html
index 0dc8bf8..29bd25c 100644
--- a/blog/classifying-iris-flowers-with-deep.html
+++ b/blog/classifying-iris-flowers-with-deep.html
@@ -53,7 +53,7 @@
 
 
 
-Blog indexClassifying Iris Flowers with Deep Learning, Groovy and 
GraalVMDeep 
LearningEncogEclipse 

(groovy-website) branch asf-site updated: clarify where `withExistingPool` static import comes from

2024-05-09 Thread paulk
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/groovy-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
 new 01910a5  clarify where `withExistingPool` static import comes from
01910a5 is described below

commit 01910a576e46c5f6e1b8cc5552ec64bffb22c645
Author: Paul King 
AuthorDate: Fri May 10 08:21:11 2024 +1000

clarify where `withExistingPool` static import comes from
---
 site/src/site/blog/gpars-meets-virtual-threads.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/site/src/site/blog/gpars-meets-virtual-threads.adoc 
b/site/src/site/blog/gpars-meets-virtual-threads.adoc
index 5ddea15..7483e96 100644
--- a/site/src/site/blog/gpars-meets-virtual-threads.adoc
+++ b/site/src/site/blog/gpars-meets-virtual-threads.adoc
@@ -56,7 +56,7 @@ assert nums.parallelStream().map(n -> n ** 2).toList() == [1, 
4, 9]
 
 Now, let's bring virtual threads into the picture. Luckily,
 GPars parallel collection facilities provide a hook for using
-an _existing_ custom executor service. This makes using virtual
+an _existing_ custom executor service (`GParsExecutorsPool.withExistingPool`). 
This makes using virtual
 threads for such code easy. First we create our pool (backed by virtual 
threads):
 
 [source,groovy]



(groovy) branch GROOVY_3_0_X updated: GROOVY-11373: SC: update error for direct target of inaccessible method

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
 new 005a3ae0e6 GROOVY-11373: SC: update error for direct target of 
inaccessible method
005a3ae0e6 is described below

commit 005a3ae0e6239af073d1d01a623a411f9a745ed9
Author: Eric Milles 
AuthorDate: Thu May 9 11:43:32 2024 -0500

GROOVY-11373: SC: update error for direct target of inaccessible method

3_0_X backport
---
 .../classgen/asm/sc/StaticInvocationWriter.java| 44 +++-
 .../classgen/asm/sc/bugs/Groovy7325Bug.groovy  | 47 ++
 2 files changed, 46 insertions(+), 45 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 8deb0d8306..ca02908926 100644
--- 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -69,9 +69,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.StringJoiner;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import static org.apache.groovy.ast.tools.ClassNodeUtils.formatTypeName;
 import static org.apache.groovy.ast.tools.ClassNodeUtils.samePackageName;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isNullConstant;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isSuperExpression;
@@ -355,16 +357,17 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return true;
 }
 
-Expression  fixedReceiver = receiver;
-boolean fixedImplicitThis = implicitThis;
-if (target.isProtected()) {
-ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, controller.getClassNode());
+Expression fixedReceiver = receiver;
+booleanfixedImplicitThis = implicitThis;
+if (target.isPackageScope()) { // GROOVY-11373
+/*if (!samePackageName(target.getDeclaringClass(), classNode)) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
+}*/
+} else if (target.isProtected()) {
+ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, classNode);
 if (!implicitThis && !isThisOrSuper(receiver) && 
!samePackageName(node, classNode)
-&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node,target.getDeclaringClass()))
 {
-controller.getSourceUnit().addError(new SyntaxException(
-"Method " + target.getName() + " is protected in " + 
target.getDeclaringClass().toString(false),
-receiver != null ? receiver : args
-));
+&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node, 
target.getDeclaringClass())) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
 } else if (!node.isDerivedFrom(target.getDeclaringClass()) && 
tryBridgeMethod(target, receiver, implicitThis, args, classNode)) {
 return true;
 }
@@ -395,6 +398,16 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return super.writeDirectMethodCall(target, implicitThis, receiver, 
args);
 }
 
+private void writeMethodAccessError(final MethodNode target, final 
Expression origin) {
+StringJoiner descriptor = new StringJoiner(", ", target.getName() + 
"(", ")");
+for (Parameter parameter : target.getParameters()) {
+descriptor.add(formatTypeName(parameter.getOriginType()));
+}
+String message = "Cannot access method: " + descriptor + " of class: " 
+ formatTypeName(target.getDeclaringClass());
+
+controller.getSourceUnit().addError(new SyntaxException(message, 
origin));
+}
+
 private boolean tryPrivateMethod(final MethodNode target, final boolean 
implicitThis, final Expression receiver, final TupleExpression args, final 
ClassNode classNode) {
 ClassNode declaringClass = target.getDeclaringClass();
 if ((isPrivateBridgeMethodsCallAllowed(declaringClass, classNode) || 
isPrivateBridgeMethodsCallAllowed(classNode, declaringClass))
@@ -402,21 +415,12 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 && !declaringClass.equals(classNode)) {
 if (tryBridgeMethod(target, receiver, implicitThis, args, 
classNode)) {
 return true;
-} else {
-checkAndAddCannotCallPrivateMetho

(groovy) branch GROOVY_4_0_X updated: GROOVY-11373: SC: cross-package direct target of package-private method

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
 new 0456e0e775 GROOVY-11373: SC: cross-package direct target of 
package-private method
0456e0e775 is described below

commit 0456e0e77567770dfdc68ca1def46c294357b99b
Author: Eric Milles 
AuthorDate: Thu May 9 11:43:32 2024 -0500

GROOVY-11373: SC: cross-package direct target of package-private method

4_0_X backport
---
 .../classgen/asm/sc/StaticInvocationWriter.java| 44 +++-
 .../sc/FieldsAndPropertiesStaticCompileTest.groovy |  9 ++---
 .../classgen/asm/sc/bugs/Groovy7325Bug.groovy  | 47 ++
 3 files changed, 50 insertions(+), 50 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 9734b1b380..2e3710c5e1 100644
--- 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -69,9 +69,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.StringJoiner;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import static org.apache.groovy.ast.tools.ClassNodeUtils.formatTypeName;
 import static org.apache.groovy.ast.tools.ClassNodeUtils.samePackageName;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isNullConstant;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isSuperExpression;
@@ -346,16 +348,17 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return true;
 }
 
-Expression  fixedReceiver = receiver;
-boolean fixedImplicitThis = implicitThis;
-if (target.isProtected()) {
-ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, controller.getClassNode());
+Expression fixedReceiver = receiver;
+booleanfixedImplicitThis = implicitThis;
+if (target.isPackageScope()) { // GROOVY-11373
+if (!samePackageName(target.getDeclaringClass(), classNode)) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
+}
+} else if (target.isProtected()) {
+ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, classNode);
 if (!implicitThis && !isThisOrSuper(receiver) && 
!samePackageName(node, classNode)
-&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node,target.getDeclaringClass()))
 {
-controller.getSourceUnit().addError(new SyntaxException(
-"Method " + target.getName() + " is protected in " + 
target.getDeclaringClass().toString(false),
-receiver != null ? receiver : args
-));
+&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node, 
target.getDeclaringClass())) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
 } else if (!node.isDerivedFrom(target.getDeclaringClass()) && 
tryBridgeMethod(target, receiver, implicitThis, args, classNode)) {
 return true;
 }
@@ -388,6 +391,16 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return super.writeDirectMethodCall(target, implicitThis, receiver, 
args);
 }
 
+private void writeMethodAccessError(final MethodNode target, final 
Expression origin) {
+StringJoiner descriptor = new StringJoiner(", ", target.getName() + 
"(", ")");
+for (Parameter parameter : target.getParameters()) {
+descriptor.add(formatTypeName(parameter.getOriginType()));
+}
+String message = "Cannot access method: " + descriptor + " of class: " 
+ formatTypeName(target.getDeclaringClass());
+
+controller.getSourceUnit().addError(new SyntaxException(message, 
origin));
+}
+
 private boolean tryPrivateMethod(final MethodNode target, final boolean 
implicitThis, final Expression receiver, final TupleExpression args, final 
ClassNode classNode) {
 ClassNode declaringClass = target.getDeclaringClass();
 if ((isPrivateBridgeMethodsCallAllowed(declaringClass, classNode) || 
isPrivateBridgeMethodsCallAllowed(classNode, declaringClass))
@@ -395,21 +408,12 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 && !declaringClass.equals(classNode)) {
 if (tryBridgeMethod(target, receiver, implicitThis, args, 
classNode)) {
 return true;
-

(groovy) branch master updated: GROOVY-11373: SC: cross-package direct target of package-private method

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
 new 131992c98e GROOVY-11373: SC: cross-package direct target of 
package-private method
131992c98e is described below

commit 131992c98e9de226aeac50917b37c4bfff31b21e
Author: Eric Milles 
AuthorDate: Thu May 9 11:43:32 2024 -0500

GROOVY-11373: SC: cross-package direct target of package-private method
---
 .../classgen/asm/sc/StaticInvocationWriter.java| 43 --
 .../sc/FieldsAndPropertiesStaticCompileTest.groovy |  9 ++---
 .../classgen/asm/sc/bugs/Groovy7325Bug.groovy  | 12 +++---
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index 0aa0e28738..4e81f7b08b 100644
--- 
a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ 
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -73,6 +73,7 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
+import static org.apache.groovy.ast.tools.ClassNodeUtils.formatTypeName;
 import static org.apache.groovy.ast.tools.ClassNodeUtils.samePackageName;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isNullConstant;
 import static org.apache.groovy.ast.tools.ExpressionUtils.isSuperExpression;
@@ -347,16 +348,17 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return true;
 }
 
-Expression  fixedReceiver = receiver;
-boolean fixedImplicitThis = implicitThis;
-if (target.isProtected()) {
-ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, controller.getClassNode());
+Expression fixedReceiver = receiver;
+booleanfixedImplicitThis = implicitThis;
+if (target.isPackageScope()) { // GROOVY-11373
+if (!samePackageName(target.getDeclaringClass(), classNode)) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
+}
+} else if (target.isProtected()) {
+ClassNode node = receiver == null ? ClassHelper.OBJECT_TYPE : 
controller.getTypeChooser().resolveType(receiver, classNode);
 if (!implicitThis && !isThisOrSuper(receiver) && 
!samePackageName(node, classNode)
-&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node,target.getDeclaringClass()))
 {
-controller.getSourceUnit().addError(new SyntaxException(
-"Method " + target.getName() + " is protected in " + 
target.getDeclaringClass().toString(false),
-receiver != null ? receiver : args
-));
+&& 
StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node, 
target.getDeclaringClass())) {
+writeMethodAccessError(target, receiver != null ? receiver : 
args);
 } else if (!node.isDerivedFrom(target.getDeclaringClass()) && 
tryBridgeMethod(target, receiver, implicitThis, args, classNode)) {
 return true;
 }
@@ -389,6 +391,16 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 return super.writeDirectMethodCall(target, implicitThis, receiver, 
args);
 }
 
+private void writeMethodAccessError(final MethodNode target, final 
Expression origin) {
+var descriptor = new java.util.StringJoiner(", ", target.getName() + 
"(", ")");
+for (Parameter parameter : target.getParameters()) {
+descriptor.add(formatTypeName(parameter.getOriginType()));
+}
+String message = "Cannot access method: " + descriptor + " of class: " 
+ formatTypeName(target.getDeclaringClass());
+
+controller.getSourceUnit().addError(new SyntaxException(message, 
origin));
+}
+
 private boolean isClassWithSuper(Expression receiver) {
 if (receiver instanceof PropertyExpression) {
 PropertyExpression pexp = (PropertyExpression) receiver;
@@ -404,21 +416,12 @@ public class StaticInvocationWriter extends 
InvocationWriter {
 && !declaringClass.equals(classNode)) {
 if (tryBridgeMethod(target, receiver, implicitThis, args, 
classNode)) {
 return true;
-} else {
-checkAndAddCannotCallPrivateMethodError(target, receiver, 
classNode, declaringClass);
 }
 }
-checkAndAddCannotCallPrivateMethodError(target, receiver, classNode, 
declaringClass);
-return false;
-}
-
-private void checkAndAddCannotCallPrivateMethodError(final MethodNode 
target, final 

(groovy) branch master updated: GROOVY-11370: add test case

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
 new 14bb43a295 GROOVY-11370: add test case
14bb43a295 is described below

commit 14bb43a29587bab7168b5b73d47338eb8ecd1a12
Author: Eric Milles 
AuthorDate: Thu May 9 09:03:04 2024 -0500

GROOVY-11370: add test case
---
 .../transform/stc/StaticTypeCheckingVisitor.java   |  2 +-
 src/test/groovy/bugs/Groovy9115.groovy | 42 +++---
 .../stc/FieldsAndPropertiesSTCTest.groovy  | 24 ++---
 .../sc/FieldsAndPropertiesStaticCompileTest.groovy | 11 --
 4 files changed, 41 insertions(+), 38 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 9e03d1e15b..f7a546c83a 100644
--- 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1708,7 +1708,7 @@ out:if ((samParameterTypes.length == 1 && 
isOrImplements(samParameterTypes[0
 foundGetterOrSetter = (foundGetterOrSetter || getter != null 
|| !setters.isEmpty());
 }
 
-// GROOVY-5568: the property may be defined by DGM
+// GROOVY-5568, GROOVY-9115, GROOVY-9123: the property may be 
defined by an extension
 for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? new 
ClassNode[]{receiverType, getWrapper(receiverType)} : new 
ClassNode[]{receiverType}) {
 Set methods = 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
getterName);
 for (MethodNode method : 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
isserName)) {
diff --git a/src/test/groovy/bugs/Groovy9115.groovy 
b/src/test/groovy/bugs/Groovy9115.groovy
index 748327ded0..900e9318fb 100644
--- a/src/test/groovy/bugs/Groovy9115.groovy
+++ b/src/test/groovy/bugs/Groovy9115.groovy
@@ -18,49 +18,47 @@
  */
 package groovy.bugs
 
-import groovy.transform.CompileStatic
 import org.junit.Test
 
 import static groovy.test.GroovyAssert.assertScript
 
-@CompileStatic
 final class Groovy9115 {
 
 @Test
-void testSetPropertyInIfStmt() {
+void testSetProperty1() {
 assertScript '''
 @groovy.transform.CompileStatic
-class Derived {
-def m() {
-if (true) {
-File file = 
File.createTempFile("hello${System.nanoTime()}", ".tmp")
-file.text = 'Groovy9115Bug'
-assert 'Groovy9115Bug' == file.text
-}
-
-return null
+void test() {
+File file = File.createTempFile('test', null)
+try {
+file.text = 'GROOVY-9115' // via 
ResourceGroovyMethods#setText
+assert file.text == 'GROOVY-9115'
+} finally {
+file.delete()
 }
 }
 
-new Derived().m()
+test()
 '''
 }
 
 @Test
-void testSetProperty() {
+void testSetProperty2() {
 assertScript '''
 @groovy.transform.CompileStatic
-class Derived {
-def m() {
-File file = 
File.createTempFile("hello${System.nanoTime()}", ".tmp")
-file.text = 'Groovy9115Bug'
-assert 'Groovy9115Bug' == file.text
-
-return null
+void test() {
+if (true) {
+File file = File.createTempFile('test', null)
+try {
+file.text = 'GROOVY-9115' // via 
ResourceGroovyMethods#setText
+assert file.text == 'GROOVY-9115'
+} finally {
+file.delete()
+}
 }
 }
 
-new Derived().m()
+test()
 '''
 }
 }
diff --git a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy 
b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
index 8a53bb662b..142ca9c548 100644
--- a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
+++ b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
@@ -686,20 +686,23 @@ class FieldsAndPropertiesSTCTest extends 
StaticTypeCheckingTestCase {
 void testMapPropertyAccess5() {
 assertScript '''
 def map = [:]
-assert map.entry == null
-assert map.empty == null
-assert map.class == null
-assert map.metaClass == null // TODO
-
-map.entry = nu

(groovy) branch GROOVY_4_0_X updated: GROOVY 11370: STC: extension method cannot provide map property

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
 new 4c8533bbd0 GROOVY 11370: STC: extension method cannot provide map 
property
4c8533bbd0 is described below

commit 4c8533bbd03ccde654a2f2070365105f1e28664f
Author: Eric Milles 
AuthorDate: Thu May 9 08:27:40 2024 -0500

GROOVY 11370: STC: extension method cannot provide map property
---
 .../transform/stc/StaticTypeCheckingVisitor.java   |  52 +++---
 src/test/groovy/bugs/Groovy9115.groovy |  42 ++---
 .../stc/FieldsAndPropertiesSTCTest.groovy  | 203 ++---
 .../sc/FieldsAndPropertiesStaticCompileTest.groovy |  39 ++--
 4 files changed, 210 insertions(+), 126 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 60b17da09c..492034f774 100644
--- 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1635,32 +1635,34 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 foundGetterOrSetter = (foundGetterOrSetter || getter != null 
|| !setters.isEmpty());
 }
 
-// GROOVY-5568: the property may be defined by DGM
-for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? new 
ClassNode[]{receiverType, getWrapper(receiverType)} : new 
ClassNode[]{receiverType}) {
-Set methods = 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
getterName);
-for (MethodNode method : 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
isserName)) {
-if (isPrimitiveBoolean(method.getReturnType())) 
methods.add(method);
-}
-if (staticOnlyAccess && receiver.getData() == null && 
!isClassType(receiver.getType())) {
-// GROOVY-10820: ensure static extension when property 
accessed in static manner
-methods.removeIf(method -> !((ExtensionMethodNode) 
method).isStaticExtension());
-}
-if (isUsingGenericsOrIsArrayUsingGenerics(dgmReceiver)) {
-methods.removeIf(method -> // GROOVY-10075: 
"List" vs "List"
-!typeCheckMethodsWithGenerics(dgmReceiver, 
ClassNode.EMPTY_ARRAY, method)
-);
-}
-if (!methods.isEmpty()) {
-List bestMethods = 
chooseBestMethod(dgmReceiver, methods, ClassNode.EMPTY_ARRAY);
-if (bestMethods.size() == 1) {
-MethodNode getter = bestMethods.get(0);
-if (visitor != null) {
-visitor.visitMethod(getter);
+if (!readMode || isThisExpression(objectExpression) || 
isSuperExpression(objectExpression) || !isOrImplements(objectExpressionType, 
MAP_TYPE)) { // GROOVY-11370
+// GROOVY-5568, GROOVY-9115, GROOVY-9123: the property may be 
defined by an extension
+for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? 
new ClassNode[]{receiverType, getWrapper(receiverType)} : new 
ClassNode[]{receiverType}) {
+Set methods = 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
getterName);
+for (MethodNode method : 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
isserName)) {
+if (isPrimitiveBoolean(method.getReturnType())) 
methods.add(method);
+}
+if (staticOnlyAccess && receiver.getData() == null && 
!isClassType(receiver.getType())) {
+// GROOVY-10820: ensure static extension when property 
accessed in static manner
+methods.removeIf(method -> !((ExtensionMethodNode) 
method).isStaticExtension());
+}
+if (isUsingGenericsOrIsArrayUsingGenerics(dgmReceiver)) {
+methods.removeIf(method -> // GROOVY-10075: 
"List" vs "List"
+!typeCheckMethodsWithGenerics(dgmReceiver, 
ClassNode.EMPTY_ARRAY, method)
+);
+}
+if (!methods.isEmpty()) {
+List bestMethods = 
chooseBestMethod(dgmReceiver, methods, ClassNode.EMPTY_ARRAY);
+if (bestMethods.size() == 1) {
+MethodNode getter = bestMethods.get(0);
+if (visitor != null) {
+visitor.visitMethod(getter);
+

(groovy) branch GROOVY_3_0_X updated: GROOVY-11370: STC: extension method cannot provide map property

2024-05-09 Thread emilles
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
 new 9d41af9df4 GROOVY-11370: STC: extension method cannot provide map 
property
9d41af9df4 is described below

commit 9d41af9df4c688ca2c91fa9283ad3462e0abc928
Author: Eric Milles 
AuthorDate: Thu May 9 07:23:15 2024 -0500

GROOVY-11370: STC: extension method cannot provide map property
---
 .../transform/stc/StaticTypeCheckingVisitor.java   |  44 ++---
 src/test/groovy/bugs/Groovy9115.groovy |  42 ++---
 .../stc/FieldsAndPropertiesSTCTest.groovy  | 204 ++---
 .../sc/FieldsAndPropertiesStaticCompileTest.groovy |   7 +
 4 files changed, 191 insertions(+), 106 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index eb162daf8d..1d8b674ecf 100644
--- 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1616,28 +1616,30 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
 foundGetterOrSetter = (foundGetterOrSetter || getter != null 
|| !setters.isEmpty());
 }
 
-// GROOVY-5568: the property may be defined by DGM
-for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? new 
ClassNode[]{receiverType, getWrapper(receiverType)} : new 
ClassNode[]{receiverType}) {
-Set methods = 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
getterName);
-for (MethodNode method : 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
isserName)) {
-if 
(Boolean_TYPE.equals(getWrapper(method.getReturnType( methods.add(method);
-}
-if (isUsingGenericsOrIsArrayUsingGenerics(dgmReceiver)) {
-methods.removeIf(method -> // GROOVY-10075: 
"List" vs "List"
-!typeCheckMethodsWithGenerics(dgmReceiver, 
ClassNode.EMPTY_ARRAY, method)
-);
-}
-if (!methods.isEmpty()) {
-List bestMethods = 
chooseBestMethod(dgmReceiver, methods, ClassNode.EMPTY_ARRAY);
-if (bestMethods.size() == 1) {
-MethodNode getter = bestMethods.get(0);
-if (visitor != null) {
-visitor.visitMethod(getter);
+if (!readMode || isThisExpression(objectExpression) || 
isSuperExpression(objectExpression) || !isOrImplements(objectExpressionType, 
MAP_TYPE)) { // GROOVY-11370
+// GROOVY-5568, GROOVY-9115, GROOVY-9123: the property may be 
defined by an extension
+for (ClassNode dgmReceiver : isPrimitiveType(receiverType) ? 
new ClassNode[]{receiverType, getWrapper(receiverType)} : new 
ClassNode[]{receiverType}) {
+Set methods = 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
getterName);
+for (MethodNode method : 
findDGMMethodsForClassNode(getSourceUnit().getClassLoader(), dgmReceiver, 
isserName)) {
+if 
(Boolean_TYPE.equals(getWrapper(method.getReturnType( methods.add(method);
+}
+if (isUsingGenericsOrIsArrayUsingGenerics(dgmReceiver)) {
+methods.removeIf(method -> // GROOVY-10075: 
"List" vs "List"
+!typeCheckMethodsWithGenerics(dgmReceiver, 
ClassNode.EMPTY_ARRAY, method)
+);
+}
+if (!methods.isEmpty()) {
+List bestMethods = 
chooseBestMethod(dgmReceiver, methods, ClassNode.EMPTY_ARRAY);
+if (bestMethods.size() == 1) {
+MethodNode getter = bestMethods.get(0);
+if (visitor != null) {
+visitor.visitMethod(getter);
+}
+ClassNode returnType = 
inferReturnTypeGenerics(dgmReceiver, getter, 
ArgumentListExpression.EMPTY_ARGUMENTS);
+storeInferredTypeForPropertyExpression(pexp, 
returnType);
+if (readMode) storeTargetMethod(pexp, getter);
+return true;
 }
-ClassNode returnType = 
inferReturnTypeGenerics(dgmReceiver, getter, 
ArgumentListExpression.EMPTY_ARGUMENTS);
-storeInferredTypeForPropertyExpression(pexp, 
returnType);
-if (readMode) storeTargetMethod(pexp