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 2020/07/05 04:52:06 UTC
[groovy] branch master updated: Revert "GROOVY-9618: index "static
getX()" as "X" if class field X also exists"
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 5416fda Revert "GROOVY-9618: index "static getX()" as "X" if class field X also exists"
5416fda is described below
commit 5416fdaa5dbe7bb437dec66e77bd1babc06265e5
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jul 5 12:51:33 2020 +0800
Revert "GROOVY-9618: index "static getX()" as "X" if class field X also exists"
See the discussion: https://github.com/apache/groovy/pull/1296
---
src/main/java/groovy/lang/MetaClassImpl.java | 15 ++++------
src/test/groovy/bugs/Groovy9618.groovy | 45 ----------------------------
2 files changed, 5 insertions(+), 55 deletions(-)
diff --git a/src/main/java/groovy/lang/MetaClassImpl.java b/src/main/java/groovy/lang/MetaClassImpl.java
index 2ada75c..63f95d3 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -2606,16 +2606,11 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
}
private static void createMetaBeanProperty(SingleKeyHashMap propertyIndex, String propName, boolean isGetter, MetaMethod propertyMethod) {
- // check if property is already accounted for
- MetaProperty oldMP = (MetaProperty) propertyIndex.get(propName);
- if (oldMP == null && propName.length() == 1 && propertyMethod.isStatic()) {
- oldMP = (MetaProperty) propertyIndex.get(propName.toUpperCase());
- if (oldMP != null) propName = propName.toUpperCase();
- }
-
- MetaProperty newMP = makeReplacementMetaProperty(oldMP, propName, isGetter, propertyMethod);
- if (newMP != oldMP) {
- propertyIndex.put(propName, newMP);
+ // is this property already accounted for?
+ MetaProperty mp = (MetaProperty) propertyIndex.get(propName);
+ MetaProperty newMp = makeReplacementMetaProperty(mp, propName, isGetter, propertyMethod);
+ if (newMp != mp) {
+ propertyIndex.put(propName, newMp);
}
}
diff --git a/src/test/groovy/bugs/Groovy9618.groovy b/src/test/groovy/bugs/Groovy9618.groovy
deleted file mode 100644
index 8fc5d31..0000000
--- a/src/test/groovy/bugs/Groovy9618.groovy
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 groovy.bugs
-
-import org.junit.Test
-
-import static groovy.test.GroovyAssert.assertScript
-
-final class Groovy9618 {
-
- @Test
- void testGetPropertyFromOuterClassOfSuper() {
- assertScript '''
- class A {
- private static X = 1
- static getX() { 2 }
- static class B { }
- }
-
- class C extends A.B {
- def m() {
- return X
- }
- }
-
- assert new C().m() == 2
- '''
- }
-}