You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/01/24 03:15:03 UTC

[groovy] 02/03: GROOVY-10434: ClassNode isSealed() refactoring (additional test)

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

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

commit 51729bee8fd7cf7312e9ca3891c5fbf70c873129
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Jan 22 22:07:47 2022 +1000

    GROOVY-10434: ClassNode isSealed() refactoring (additional test)
---
 .../groovy/transform/SealedTransformTest.groovy       | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy b/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
index 939c155..d838cda 100644
--- a/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/SealedTransformTest.groovy
@@ -235,7 +235,7 @@ class SealedTransformTest {
     }
 
     @Test
-    void testClassNodeIsSealed() {
+    void testClassNodeIsSealedExplicitSubclasses() {
         assertScript '''
             import groovy.transform.*
             import org.codehaus.groovy.control.CompilePhase
@@ -244,7 +244,22 @@ class SealedTransformTest {
                 assert node.isSealed()
             })
             sealed class Foo permits Bar {}
-            final class Bar {}
+            final class Bar extends Foo {}
+            new Foo()
+        '''
+    }
+
+    @Test
+    void testClassNodeIsSealedImplicitSubclasses() {
+        assertScript '''
+            import groovy.transform.*
+            import org.codehaus.groovy.control.CompilePhase
+            @ASTTest(phase = CompilePhase.CANONICALIZATION, value = {
+                assert node.permittedSubclasses*.name == ['Bar']
+                assert node.isSealed()
+            })
+            sealed class Foo {}
+            final class Bar extends Foo {}
             new Foo()
         '''
     }