This is an automated email from the ASF dual-hosted git repository.

jdaugherty pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/grails-intellij-plugin.git


The following commit(s) were added to refs/heads/main by this push:
     new 47b1836  Extract collection element type for Groovy synthetic 
collections on 2026.2
47b1836 is described below

commit 47b183623846c0a6d4239b7e8aadd4c981dc1420
Author: James Daugherty <[email protected]>
AuthorDate: Sat Jul 18 23:45:48 2026 -0400

    Extract collection element type for Groovy synthetic collections on 2026.2
    
    Since IntelliJ 2026.2, PsiUtil.extractIterableTypeParameter() returns null 
for
    Groovy synthetic collection types (ListLiteralType, GrClassReferenceType) 
whose
    Iterable supertype is not walkable in the given scope. Anything deriving an
    element type from such a collection got the whole collection type instead:
    GSP <g:each>/<g:collect>/<g:findAll> loop variables, <g:select> options, and
    model variables.
    
    Fall back to the sole type argument as the element type when 
iterable-parameter
    extraction fails. Fixes GspSelectTagTest and 
GspResolveVariablesFromModelTest
    and several GspResolveIndexesTest cases.
---
 src/org/jetbrains/plugins/grails/util/GrailsPsiUtil.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/org/jetbrains/plugins/grails/util/GrailsPsiUtil.java 
b/src/org/jetbrains/plugins/grails/util/GrailsPsiUtil.java
index f73e38b..7dcee2c 100644
--- a/src/org/jetbrains/plugins/grails/util/GrailsPsiUtil.java
+++ b/src/org/jetbrains/plugins/grails/util/GrailsPsiUtil.java
@@ -323,7 +323,7 @@ public final class GrailsPsiUtil {
     PsiType res = PsiUtil.extractIterableTypeParameter(psiType, true);
     if (res != null) return res;
 
-    if (!(psiType instanceof PsiClassType)) return psiType;
+    if (!(psiType instanceof PsiClassType classType)) return psiType;
 
     JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
     PsiElementFactory factory = facade.getElementFactory();
@@ -334,6 +334,13 @@ public final class GrailsPsiUtil {
       return 
factory.createTypeByFQClassName(CommonClassNames.JAVA_UTIL_MAP_ENTRY, scope);
     }
 
+    // Since IntelliJ 2026.2, PsiUtil.extractIterableTypeParameter() returns 
null for Groovy
+    // synthetic collection types (ListLiteralType, GrClassReferenceType) 
whose Iterable supertype
+    // is not walkable in this scope. Fall back to the sole type argument as 
the element type.
+    if (classType.getParameterCount() == 1) {
+      return classType.getParameters()[0];
+    }
+
     return psiType;
   }
 

Reply via email to