From 56863662d535718a8130c41f6915be92c87278db Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 27 Jun 1999 21:00:33 +0000 Subject: [PATCH] better this. handling (NOSUPER...NAME) git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@930 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/expr/GetFieldOperator.java | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/jode/jode/expr/GetFieldOperator.java b/jode/jode/expr/GetFieldOperator.java index c2eba47..87fca84 100644 --- a/jode/jode/expr/GetFieldOperator.java +++ b/jode/jode/expr/GetFieldOperator.java @@ -148,8 +148,21 @@ public class GetFieldOperator extends Operator { */ getField() == null && writer.conflicts(fieldName, null, - Scope.FIELDNAME))) { - writer.print("this."); + Scope.NOSUPERFIELDNAME))) { + + ClassAnalyzer ana = methodAnalyzer.getClassAnalyzer(); + while (ana.getParent() instanceof ClassAnalyzer + && ana != scope) + ana = (ClassAnalyzer) ana.getParent(); + if (ana == scope) + // For a simple outer class we can say this + writer.print("this."); + else { + // For a class that owns a method that owns + // us, we have to give the full class name + thisOp.dumpExpression(writer, 950); + writer.print("."); + } } } else { subExpressions[0].dumpExpression(writer, 950); @@ -165,8 +178,12 @@ public class GetFieldOperator extends Operator { subExpressions[0].parent = this; if (subExpressions[0] instanceof ThisOperator) { FieldAnalyzer field = getField(); - if (field != null - && field.isSynthetic() && field.isFinal()) { + /* This should check for isFinal(), but sadly, + * sometimes jikes doesn't make a val$ field final. I + * don't know when, or why, so I currently ignore + * isFinal. + */ + if (field != null && field.isSynthetic()) { Expression constant = field.getConstant(); if (constant instanceof ThisOperator || constant instanceof OuterLocalOperator)