IDEA-149813 Decompiler has lost generic parameter

This commit is contained in:
Egor.Ushakov
2017-01-10 12:03:26 +03:00
parent fe5260df8a
commit 32693c314a
8 changed files with 126 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,15 @@ import org.jetbrains.java.decompiler.main.ClassesProcessor.ClassNode;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.main.TextBuffer;
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger;
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.vars.CheckTypesResult;
import org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionPair;
import org.jetbrains.java.decompiler.struct.StructClass;
import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.struct.gen.generics.GenericClassDescriptor;
import org.jetbrains.java.decompiler.struct.gen.generics.GenericMain;
import org.jetbrains.java.decompiler.util.InterpreterUtil;
import org.jetbrains.java.decompiler.util.ListStack;
@@ -181,7 +184,23 @@ public class NewExprent extends Exprent {
typename = typename.substring(typename.lastIndexOf('.') + 1);
}
}
buf.append(typename);
GenericClassDescriptor descriptor = ClassWriter.getGenericClassDescriptor(child.classStruct);
if (descriptor != null) {
if (descriptor.superinterfaces.isEmpty()) {
buf.append(GenericMain.getGenericCastTypeName(descriptor.superclass));
}
else {
if (descriptor.superinterfaces.size() > 1) {
DecompilerContext.getLogger().writeMessage("Inconsistent anonymous class signature: " + child.classStruct.qualifiedName,
IFernflowerLogger.Severity.WARN);
}
buf.append(GenericMain.getGenericCastTypeName(descriptor.superinterfaces.get(0)));
}
}
else {
buf.append(typename);
}
}
buf.append('(');