You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/12/17 09:36:17 UTC
[groovy] branch GROOVY-10877 created (now 140cab176f)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch GROOVY-10877
in repository https://gitbox.apache.org/repos/asf/groovy.git
at 140cab176f GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
This branch includes the following new commits:
new 140cab176f GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[groovy] 01/01: GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-10877
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 140cab176f9ebb2f328b5c21a91741da230e1c7e
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Dec 17 17:36:02 2022 +0800
GROOVY-10877: Record with ThreadInterruptibleASTTransformation applied fails to run
---
.../ThreadInterruptibleASTTransformation.groovy | 3 ++-
src/test/groovy/transform/ThreadInterruptTest.groovy | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
index 459a94b829..396b2dd77c 100644
--- a/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
+++ b/src/main/groovy/org/codehaus/groovy/transform/ThreadInterruptibleASTTransformation.groovy
@@ -85,7 +85,8 @@ class ThreadInterruptibleASTTransformation extends AbstractInterruptibleASTTrans
@Override
void visitMethod(MethodNode node) {
- if (checkOnMethodStart && !node.isSynthetic() && !node.isAbstract()) {
+ if (checkOnMethodStart && !node.isSynthetic() && !node.isAbstract()
+ && !(node.getDeclaringClass().isRecord() && node.annotations?.any(e -> 'groovy.transform.Generated' == e.classNode.name))) {
def code = node.code
node.code = wrapBlock(code)
}
diff --git a/src/test/groovy/transform/ThreadInterruptTest.groovy b/src/test/groovy/transform/ThreadInterruptTest.groovy
index 95cd0242ec..484f87e48e 100644
--- a/src/test/groovy/transform/ThreadInterruptTest.groovy
+++ b/src/test/groovy/transform/ThreadInterruptTest.groovy
@@ -397,6 +397,23 @@ final class ThreadInterruptTest {
shouldFail(shell, InterruptedException, script)
}
}
+
+ // GROOVY-10877
+ @Test
+ void testThreadInterruptOnRecord() {
+ assertScript '''
+ @groovy.transform.ThreadInterrupt
+ record Point(int x, int y) {
+ String report() {
+ "$x, $y"
+ }
+ }
+
+ def p = new Point(1, 2)
+ assert 'Point[x=1, y=2]' == p.toString()
+ assert '1, 2' == p.report()
+ '''
+ }
}
//--------------------------------------------------------------------------