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 2021/04/01 04:30:43 UTC

[groovy] 06/10: GROOVY-9993: Field and a property with the same name: clarification of boundary cases (delayed checking of duplicate fields and properties)

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

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

commit be41cee8ce94996dd3385e559e7936271337a414
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Mar 30 21:03:06 2021 +1000

    GROOVY-9993: Field and a property with the same name: clarification of boundary cases (delayed checking of duplicate fields and properties)
---
 .../java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java b/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
index a199fae..fb26380 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ClassCompletionVerifier.java
@@ -293,6 +293,10 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
         return "field '" + node.getName() + "'";
     }
 
+    private static String getDescription(PropertyNode node) {
+        return "property '" + node.getName() + "'";
+    }
+
     private static String getDescription(Parameter node) {
         return "parameter '" + node.getName() + "'";
     }
@@ -537,6 +541,9 @@ public class ClassCompletionVerifier extends ClassCodeVisitorSupport {
 
     @Override
     public void visitProperty(PropertyNode node) {
+        if (currentClass.getProperty(node.getName()) != node) {
+            addError("The " + getDescription(node) + " is declared multiple times.", node);
+        }
         checkDuplicateProperties(node);
         checkGenericsUsage(node, node.getType());
         super.visitProperty(node);