Fixed 'IDEA-128676: Initializer in a nested class disappears'

This commit is contained in:
Stiver 2014-08-15 18:58:55 +02:00
parent 887c093afd
commit c672e5bc83
2 changed files with 7 additions and 1 deletions

View File

@ -208,7 +208,9 @@ public class InitializerProcessor {
AssignmentExprent asexpr = (AssignmentExprent)exprent;
if(asexpr.getLeft().type == Exprent.EXPRENT_FIELD) {
FieldExprent fexpr = (FieldExprent)asexpr.getLeft();
if(!fexpr.isStatic() && fexpr.getClassname().equals(cl.qualifiedName)) {
if(!fexpr.isStatic() && fexpr.getClassname().equals(cl.qualifiedName) &&
cl.hasField(fexpr.getName(), fexpr.getDescriptor().descriptorString)) { // check for the physical existence of the field. Could be defined in a superclass.
if(isExprentIndependent(asexpr.getRight(), lstMethWrappers.get(i))) {
String fieldKey = InterpreterUtil.makeUniqueKey(fexpr.getName(), fexpr.getDescriptor().descriptorString);
if(fieldWithDescr == null) {

View File

@ -118,6 +118,10 @@ public class StructClass {
// public methods
// *****************************************************************************
public boolean hasField(String name, String descriptor) {
return getField(name, descriptor) != null;
}
public StructField getField(String name, String descriptor) {
return fields.getWithKey(InterpreterUtil.makeUniqueKey(name, descriptor));
}