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

sunlan pushed a commit to branch GROOVY-9631
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY-9631 by this push:
     new 30849d2  Trivial refactoring
30849d2 is described below

commit 30849d2ca3f1dcccd9cde6a57c06b4b22d926679
Author: Daniel Sun <sun...@apache.org>
AuthorDate: Sun Jul 12 22:50:21 2020 +0800

    Trivial refactoring
---
 src/main/java/groovy/lang/MetaClassImpl.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index 833ad67..c98b923 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -2330,14 +2330,12 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
      *
      * @param propertyDescriptors the property descriptors
      */
-    @SuppressWarnings("unchecked")
     private void setupProperties(PropertyDescriptor[] propertyDescriptors) {
         if (theCachedClass.isInterface) {
             LinkedList<CachedClass> superClasses = new LinkedList<>();
             superClasses.add(ReflectionCache.OBJECT_CLASS);
-            Set interfaces = theCachedClass.getInterfaces();
+            LinkedList<CachedClass> superInterfaces = new 
LinkedList<>(theCachedClass.getInterfaces());
 
-            LinkedList<CachedClass> superInterfaces = new 
LinkedList<CachedClass>(interfaces);
             // sort interfaces so that we may ensure a deterministic behaviour 
in case of
             // ambiguous fields (class implementing two interfaces using the 
same field)
             if (superInterfaces.size() > 1) {
@@ -2358,11 +2356,12 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
             makeStaticPropertyIndex();
         } else {
             LinkedList<CachedClass> superClasses = getSuperClasses();
-            LinkedList<CachedClass> interfaces = new 
LinkedList<>(theCachedClass.getInterfaces());
+            LinkedList<CachedClass> superInterfaces = new 
LinkedList<>(theCachedClass.getInterfaces());
+
             // sort interfaces so that we may ensure a deterministic behaviour 
in case of
             // ambiguous fields (class implementing two interfaces using the 
same field)
-            if (interfaces.size() > 1) {
-                interfaces.sort(CACHED_CLASS_NAME_COMPARATOR);
+            if (superInterfaces.size() > 1) {
+                superInterfaces.sort(CACHED_CLASS_NAME_COMPARATOR);
             }
 
             // if this an Array, then add the special read-only "length" 
property
@@ -2372,7 +2371,7 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                 classPropertyIndex.put(theCachedClass, map);
             }
 
-            inheritStaticInterfaceFields(superClasses, new 
LinkedHashSet(interfaces));
+            inheritStaticInterfaceFields(superClasses, new 
LinkedHashSet<>(superInterfaces));
             inheritFields(superClasses);
 
             applyPropertyDescriptors(propertyDescriptors);

Reply via email to