Changeset 2822


Ignore:
Timestamp:
02/22/05 14:48:53 (8 years ago)
Author:
hauma
Message:

Follow-up for [888], resolution to reopened ticket:63.

  • Only generate fully qualified accesses, if the accessed variable belongs to an enclosing class. Otherwise generate an access through this.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gj/src/gjc/v6/jp/TransBody.java

    r2544 r2822  
    397397                        // Find referenced enclosing type the accessed 
    398398                        // variable belongs to. See See: BUG/0063 
     399                        boolean definedInOuterClass = false; 
    399400                        Type vowner = var.owner.type; 
    400401                        Type cclazz = c.clazz.type; 
    401402                        while (! cclazz.subType(vowner)) { 
    402403                            cclazz = cclazz.outer(); 
     404                            definedInOuterClass = true; 
    403405                        } 
    404406 
     
    412414                            c.f.at(Position.NOPOS); 
    413415                            ref = c.f.Ident(Names._this); 
    414                         } else if (tools.isFinal(var)) { 
    415                             // This is another great hack, because 
    416                             // final variables can not be initialized 
    417                             // with a fully qualified name, even with 
    418                             // javac. Is this a bug in javac and gj? 
    419                             c.f.at(Position.NOPOS); 
    420                             ref = c.f.Ident(Names._this); 
    421416                        } else if (! tools.hasRef(cclazz.tsym)) { 
    422417                            // A instance variable of an anonymous 
     
    426421                            ref = null; 
    427422                        } else { 
    428                             c.f.at(Position.NOPOS); 
    429                             ref = c.f.Select(tools.getRef(cclazz.tsym), Names._this); 
     423                            if (definedInOuterClass) { 
     424                                c.f.at(Position.NOPOS); 
     425                                ref = c.f.Select(tools.getRef(cclazz.tsym), Names._this); 
     426                            } else { 
     427                                c.f.at(Position.NOPOS); 
     428                                ref = c.f.Ident(Names._this); 
     429                            } 
    430430                        } 
    431431                        isStaticRef = false; 
Note: See TracChangeset for help on using the changeset viewer.