Skip to content

Commit

Permalink
GROOVY-6954, GROOVY-11376
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed May 14, 2024
1 parent d2f77bc commit 972d34a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,41 @@ public void testCompileStatic6904() {
runConformTest(sources, "works");
}

@Test
public void testCompileStatic6954() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import groovy.transform.*\n" +
"@CompileStatic class C extends HashMap<String,String> {\n" +
" def a\n" +
" public b\n" +
" protected c\n" +
" @PackageScope d\n" +
" private e\n" +
" C() {\n" +
" this.a = 'a'\n" +
" this.b = 'b'\n" +
" this.c = 'c'\n" +
" this.d = 'd'\n" +
" this.e = 'e'\n" +
" print(this);\n" +
"def that = this;\n" +
" that.a = 'a'\n" + // not put
" that.b = 'b'\n" + // not put
" that.c = 'c'\n" + // not put
" that.d = 'd'\n" +
" that.e = 'e'\n" +
" print(that);\n" +
" }\n" +
"}\n" +
"new C()\n",
};
//@formatter:on

runConformTest(sources, "[:][d:d, e:e]");
}

@Test
public void testCompileStatic6921() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,10 @@ public void fallbackAttributeOrPropertySite(final PropertyExpression expression,
}
}
}
// GRECLIPSE add -- GROOVY-6954
if (isOrImplements(receiverType, MAP_TYPE) && !isClassReceiver[0]) {
// GRECLIPSE add -- GROOVY-6954, GROOVY-11376
if (!isClassReceiver[0] && isOrImplements(receiverType, MAP_TYPE) &&
!java.util.Optional.ofNullable(getField(receiverType, name))
.filter(f -> f.isPublic() || f.isProtected()).isPresent()) {
MethodVisitor mv = controller.getMethodVisitor();

// store value in temporary variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,13 @@ public void fallbackAttributeOrPropertySite(final PropertyExpression expression,
}
}
}
/* GRECLIPSE edit -- GROOVY-11376
if (isOrImplements(receiverType, MAP_TYPE) && !isClassReceiver[0]) {
*/
if (!isClassReceiver[0] && isOrImplements(receiverType, MAP_TYPE) &&
!java.util.Optional.ofNullable(getField(receiverType, name))
.filter(f -> f.isPublic() || f.isProtected()).isPresent()) {
// GRECLIPSE end
MethodVisitor mv = controller.getMethodVisitor();

// store value in temporary variable
Expand Down

0 comments on commit 972d34a

Please sign in to comment.