This is an automated email from the ASF dual-hosted git repository.
sunlan 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 c64a93b993 GROOVY-11831: Compiler crash with TYPE_USE annotation on
void method during AST transformation
c64a93b993 is described below
commit c64a93b993fabe12ec41f3d15addb7d4263ca213
Author: Paul King <[email protected]>
AuthorDate: Sat Jan 10 15:12:56 2026 +1000
GROOVY-11831: Compiler crash with TYPE_USE annotation on void method during
AST transformation
---
.../codehaus/groovy/classgen/ExtendedVerifier.java | 5 ++-
.../groovy/classgen/ExtendedVerifierTest.groovy | 42 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
b/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
index 9b38699ff7..9649ab87c4 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
@@ -66,6 +66,7 @@ import static
org.codehaus.groovy.ast.AnnotationNode.TYPE_PARAMETER_TARGET;
import static org.codehaus.groovy.ast.AnnotationNode.TYPE_TARGET;
import static org.codehaus.groovy.ast.AnnotationNode.TYPE_USE_TARGET;
import static org.codehaus.groovy.ast.ClassHelper.DEPRECATED_TYPE;
+import static org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid;
import static org.codehaus.groovy.ast.ClassHelper.makeCached;
import static org.codehaus.groovy.ast.tools.GeneralUtils.listX;
import static
org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpec;
@@ -219,7 +220,9 @@ public class ExtendedVerifier extends
ClassCodeVisitorSupport {
visitAnnotations(node, METHOD_TARGET);
visitTypeAnnotations(node.getReturnType());
visitConstructorOrMethod(node);
- extractTypeUseAnnotations(node.getAnnotations(), node.getReturnType(),
METHOD_TARGET);
+ if (!isPrimitiveVoid(node.getReturnType())) {
+ extractTypeUseAnnotations(node.getAnnotations(),
node.getReturnType(), METHOD_TARGET);
+ }
}
//--------------------------------------------------------------------------
diff --git
a/src/test/groovy/org/codehaus/groovy/classgen/ExtendedVerifierTest.groovy
b/src/test/groovy/org/codehaus/groovy/classgen/ExtendedVerifierTest.groovy
new file mode 100644
index 0000000000..82858c52aa
--- /dev/null
+++ b/src/test/groovy/org/codehaus/groovy/classgen/ExtendedVerifierTest.groovy
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.codehaus.groovy.classgen
+
+import org.codehaus.groovy.ast.ClassHelper
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.MethodNode
+import org.codehaus.groovy.ast.Parameter
+import org.codehaus.groovy.control.SourceUnit
+import org.junit.jupiter.api.Test
+
+import static org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE
+import static org.codehaus.groovy.ast.tools.GeneralUtils.block
+import static org.objectweb.asm.Opcodes.ACC_PUBLIC
+
+final class ExtendedVerifierTest {
+
+ @Test
+ void testNoTypeUseAnnotationsForVoidMethod() {
+ ClassNode cn = new ClassNode('DummyClass', ACC_PUBLIC, OBJECT_TYPE)
+ MethodNode mn = cn.addMethod("dummyMethod", ACC_PUBLIC,
ClassHelper.VOID_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, block())
+ mn.addAnnotation(ClassHelper.makeWithoutCaching('groovy.lang.Grapes'))
+ new ExtendedVerifier(new SourceUnit((String)'dummySU', null, null,
null, null)).visitClass(cn)
+ assert mn.returnType.annotations.isEmpty()
+ }
+}