86
86
import static org .codehaus .groovy .ast .tools .GeneralUtils .args ;
87
87
import static org .codehaus .groovy .ast .tools .GeneralUtils .callX ;
88
88
import static org .codehaus .groovy .ast .tools .GeneralUtils .constX ;
89
- import static org .codehaus .groovy .classgen .AsmClassGenerator .samePackages ;
90
89
import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .chooseBestMethod ;
91
90
import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .findDGMMethodsByNameAndArguments ;
92
91
import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .implementsInterfaceOrIsSubclassOf ;
@@ -561,10 +560,15 @@ private boolean makeGetPropertyWithGetter(final Expression receiver, final Class
561
560
}
562
561
563
562
boolean makeGetField (final Expression receiver , final ClassNode receiverType , final String fieldName , final boolean safe , final boolean implicitThis ) {
563
+ /* GRECLIPSE edit -- GROOVY-7039, GROOVY-9791
564
564
FieldNode field = receiverType.getField(fieldName);
565
565
// direct access is allowed if we are in the same class as the declaring class
566
566
// or we are in an inner class
567
567
if (field != null && isDirectAccessAllowed(field, controller.getClassNode())) {
568
+ */
569
+ FieldNode field = org .apache .groovy .ast .tools .ClassNodeUtils .getField (receiverType , fieldName );
570
+ if (field != null && AsmClassGenerator .isValidFieldNodeForByteCodeAccess (field , controller .getClassNode ())) {
571
+ // GRECLIPSE end
568
572
CompileStack compileStack = controller .getCompileStack ();
569
573
MethodVisitor mv = controller .getMethodVisitor ();
570
574
ClassNode replacementType = field .getOriginType ();
@@ -604,7 +608,7 @@ boolean makeGetField(final Expression receiver, final ClassNode receiverType, fi
604
608
operandStack .replace (replacementType );
605
609
return true ;
606
610
}
607
-
611
+ /* GRECLIPSE edit
608
612
for (ClassNode intf : receiverType.getInterfaces()) {
609
613
// GROOVY-7039
610
614
if (intf != receiverType && makeGetField(receiver, intf, fieldName, safe, implicitThis)) {
@@ -616,9 +620,11 @@ boolean makeGetField(final Expression receiver, final ClassNode receiverType, fi
616
620
if (superClass != null) {
617
621
return makeGetField(receiver, superClass, fieldName, safe, implicitThis);
618
622
}
623
+ */
619
624
return false ;
620
625
}
621
626
627
+ /* GRECLIPSE edit -- GROOVY-9791
622
628
private static boolean isDirectAccessAllowed(FieldNode field, ClassNode receiver) {
623
629
ClassNode declaringClass = field.getDeclaringClass().redirect();
624
630
ClassNode receiverType = receiver.redirect();
@@ -639,6 +645,7 @@ private static boolean isDirectAccessAllowed(FieldNode field, ClassNode receiver
639
645
// finally public and visible
640
646
return field.isPublic() || samePackages(receiver.getPackageName(), declaringClass.getPackageName());
641
647
}
648
+ */
642
649
643
650
@ Override
644
651
public void makeSiteEntry () {
@@ -946,7 +953,7 @@ private boolean setField(PropertyExpression expression, Expression objectExpress
946
953
return true ;
947
954
}
948
955
949
- @ SuppressWarnings ( "unused" )
956
+ /* GRECLIPSE edit
950
957
private boolean getField(PropertyExpression expression, Expression receiver, ClassNode receiverType, String name) {
951
958
boolean safe = expression.isSafe();
952
959
boolean implicitThis = expression.isImplicitThis();
@@ -971,6 +978,7 @@ private boolean getField(PropertyExpression expression, Expression receiver, Cla
971
978
}
972
979
return false;
973
980
}
981
+ */
974
982
975
983
private void addPropertyAccessError (final Expression receiver , final String propertyName , final ClassNode receiverType ) {
976
984
String receiverName = (receiver instanceof ClassExpression ? receiver .getType () : receiverType ).toString (false );
0 commit comments