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
The following commit(s) were added to refs/heads/master by this push:
new dbc4903 GROOVY-9825: interface constants from super interfaces lost
in some contexts (closes #1429)
dbc4903 is described below
commit dbc49039ab7f424ab970990a55ccba9cba3a6876
Author: Paul King <[email protected]>
AuthorDate: Mon Nov 23 15:49:17 2020 +1000
GROOVY-9825: interface constants from super interfaces lost in some
contexts (closes #1429)
---
.../groovy/classgen/VariableScopeVisitor.java | 2 +-
src/test/gls/innerClass/InnerClassTest.groovy | 24 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git
a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
index 411d51a..7513f60 100644
--- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -195,7 +195,7 @@ public class VariableScopeVisitor extends
ClassCodeVisitorSupport {
}
}
- for (ClassNode face : cn.getInterfaces()) {
+ for (ClassNode face : cn.getAllInterfaces()) {
FieldNode fn = face.getDeclaredField(name);
if (fn != null) return fn;
}
diff --git a/src/test/gls/innerClass/InnerClassTest.groovy
b/src/test/gls/innerClass/InnerClassTest.groovy
index ebb0b5a..9f4f842 100644
--- a/src/test/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/gls/innerClass/InnerClassTest.groovy
@@ -92,6 +92,30 @@ final class InnerClassTest {
'''
}
+ @Test // GROOVY-9825
+ void testAccessSuperInterfaceConstantWithInnerClass() {
+ assertScript '''
+ class Baz {
+ static void main(args) {
+ assert new Inner().inner() == 1
+ }
+ static class Inner implements Bar {
+ def inner() {
+ FOO
+ }
+ }
+ }
+
+ interface Foo {
+ int FOO = 1
+ }
+
+ interface Bar extends Foo {
+ int BAR = 3
+ }
+ '''
+ }
+
@Test // GROOVY-9499
void testAccessStaticMethodFromAICInSuperCtorCall() {
assertScript '''