8686import static org .codehaus .groovy .ast .tools .GeneralUtils .args ;
8787import static org .codehaus .groovy .ast .tools .GeneralUtils .callX ;
8888import static org .codehaus .groovy .ast .tools .GeneralUtils .constX ;
89- import static org .codehaus .groovy .classgen .AsmClassGenerator .samePackages ;
9089import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .chooseBestMethod ;
9190import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .findDGMMethodsByNameAndArguments ;
9291import static org .codehaus .groovy .transform .stc .StaticTypeCheckingSupport .implementsInterfaceOrIsSubclassOf ;
@@ -561,10 +560,15 @@ private boolean makeGetPropertyWithGetter(final Expression receiver, final Class
561560 }
562561
563562 boolean makeGetField (final Expression receiver , final ClassNode receiverType , final String fieldName , final boolean safe , final boolean implicitThis ) {
563+ /* GRECLIPSE edit -- GROOVY-7039, GROOVY-9791
564564 FieldNode field = receiverType.getField(fieldName);
565565 // direct access is allowed if we are in the same class as the declaring class
566566 // or we are in an inner class
567567 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
568572 CompileStack compileStack = controller .getCompileStack ();
569573 MethodVisitor mv = controller .getMethodVisitor ();
570574 ClassNode replacementType = field .getOriginType ();
@@ -604,7 +608,7 @@ boolean makeGetField(final Expression receiver, final ClassNode receiverType, fi
604608 operandStack .replace (replacementType );
605609 return true ;
606610 }
607-
611+ /* GRECLIPSE edit
608612 for (ClassNode intf : receiverType.getInterfaces()) {
609613 // GROOVY-7039
610614 if (intf != receiverType && makeGetField(receiver, intf, fieldName, safe, implicitThis)) {
@@ -616,9 +620,11 @@ boolean makeGetField(final Expression receiver, final ClassNode receiverType, fi
616620 if (superClass != null) {
617621 return makeGetField(receiver, superClass, fieldName, safe, implicitThis);
618622 }
623+ */
619624 return false ;
620625 }
621626
627+ /* GRECLIPSE edit -- GROOVY-9791
622628 private static boolean isDirectAccessAllowed(FieldNode field, ClassNode receiver) {
623629 ClassNode declaringClass = field.getDeclaringClass().redirect();
624630 ClassNode receiverType = receiver.redirect();
@@ -639,6 +645,7 @@ private static boolean isDirectAccessAllowed(FieldNode field, ClassNode receiver
639645 // finally public and visible
640646 return field.isPublic() || samePackages(receiver.getPackageName(), declaringClass.getPackageName());
641647 }
648+ */
642649
643650 @ Override
644651 public void makeSiteEntry () {
@@ -946,7 +953,7 @@ private boolean setField(PropertyExpression expression, Expression objectExpress
946953 return true ;
947954 }
948955
949- @ SuppressWarnings ( "unused" )
956+ /* GRECLIPSE edit
950957 private boolean getField(PropertyExpression expression, Expression receiver, ClassNode receiverType, String name) {
951958 boolean safe = expression.isSafe();
952959 boolean implicitThis = expression.isImplicitThis();
@@ -971,6 +978,7 @@ private boolean getField(PropertyExpression expression, Expression receiver, Cla
971978 }
972979 return false;
973980 }
981+ */
974982
975983 private void addPropertyAccessError (final Expression receiver , final String propertyName , final ClassNode receiverType ) {
976984 String receiverName = (receiver instanceof ClassExpression ? receiver .getType () : receiverType ).toString (false );
0 commit comments