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 d53e4e4 Revert "GROOVY-8955: allow "def" as universal non-primitive
return type"
d53e4e4 is described below
commit d53e4e461bc6e08a7d265258db9d00e86d873691
Author: Daniel Sun <[email protected]>
AuthorDate: Sat Jun 29 01:12:39 2019 +0800
Revert "GROOVY-8955: allow "def" as universal non-primitive return type"
https://github.com/apache/groovy/commit/23ea427dfff1623550e3f83c8b1a5f31ab944a8a#commitcomment-33849377
Paul King said:
I am wondering if this needs more work? If in the test I replace the
`getMapping()` method with:
```
// "def" instead of explicit replacement for "T extends
Property"
def getMappedForm() {
new Date()
}
```
I get a runtime exception:
```
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast
object 'Fri Jun 07 19:49:19 AEST 2019' with class 'java.util.Date' to class
'Property'
```
Perhaps we should address that before making this commit?
---
.../org/codehaus/groovy/classgen/Verifier.java | 7 +--
src/test/groovy/bugs/Groovy8955.groovy | 70 ----------------------
2 files changed, 1 insertion(+), 76 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
index dc9fa2f..79c200e 100644
--- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java
@@ -1358,7 +1358,7 @@ public class Verifier implements GroovyClassVisitor,
Opcodes {
if (equalReturnType && normalEqualParameters) return null;
- if (oldMethod.isFinal()) {
+ if ((oldMethod.getModifiers() & ACC_FINAL) != 0) {
throw new RuntimeParserException(
"Cannot override final method " +
oldMethod.getTypeDescriptor() +
@@ -1392,11 +1392,6 @@ public class Verifier implements GroovyClassVisitor,
Opcodes {
message,
overridingMethod);
}
- // GROOVY-8955 -- allow "def" as universal non-primitive return
type
- if (overridingMethod.isDynamicReturnType() &&
normalEqualParameters) {
- overridingMethod.setReturnType(cleanType(omr));
- return null;
- }
}
// if we reach this point we have at least one parameter or return
type, that
diff --git a/src/test/groovy/bugs/Groovy8955.groovy
b/src/test/groovy/bugs/Groovy8955.groovy
deleted file mode 100644
index e3746f3..0000000
--- a/src/test/groovy/bugs/Groovy8955.groovy
+++ /dev/null
@@ -1,70 +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 groovy.transform.CompileStatic
-
-@CompileStatic
-final class Groovy8955 extends GroovyTestCase {
-
- void testAnoymousInner_DefForGenericReturnType() {
- assertScript '''
- class Property {
- String generator
- }
-
- interface PMapping<T extends Property> {
- T getMappedForm()
- }
-
- interface PProperty {
- PMapping getMapping()
- }
-
- @groovy.transform.CompileStatic
- class GPEntity {
- PProperty getIdentity() {
- new PProperty() {
- PMapping getMapping() {
- new PMapping() {
- // "def" instead of explicit replacement for
"T extends Property"
- def getMappedForm() {
- new Property() {
- @Override
- String getGenerator() {
- 'foo'
- }
- }
- }
- }
- }
- }
- }
-
- def method() {
- PProperty id = getIdentity()
- PMapping map = id.getMapping()
- map.getMappedForm().getGenerator()
- }
- }
-
- assert new GPEntity().method() == 'foo'
- '''
- }
-}