Invoke "remove unnecessary final" intention in compiler modules

This commit is contained in:
Alexander Udalov
2017-04-01 00:23:37 +03:00
parent 463bbbd386
commit 34f0576135
96 changed files with 407 additions and 404 deletions
@@ -34,7 +34,7 @@ public abstract class AbstractControlFlowTest extends AbstractPseudocodeTest {
@NotNull StringBuilder out,
@NotNull BindingContext bindingContext
) {
final int nextInstructionsColumnWidth = countNextInstructionsColumnWidth(pseudocode.getInstructionsIncludingDeadCode());
int nextInstructionsColumnWidth = countNextInstructionsColumnWidth(pseudocode.getInstructionsIncludingDeadCode());
dumpInstructions(pseudocode, out, new Function3<Instruction, Instruction, Instruction, String>() {
@Override
@@ -39,13 +39,13 @@ public abstract class AbstractDataFlowTest extends AbstractPseudocodeTest {
@NotNull BindingContext bindingContext
) {
PseudocodeVariablesData pseudocodeVariablesData = new PseudocodeVariablesData(pseudocode.getRootPseudocode(), bindingContext);
final Map<Instruction, Edges<InitControlFlowInfo>> variableInitializers =
Map<Instruction, Edges<InitControlFlowInfo>> variableInitializers =
pseudocodeVariablesData.getVariableInitializers();
final Map<Instruction, Edges<UseControlFlowInfo>> useStatusData =
Map<Instruction, Edges<UseControlFlowInfo>> useStatusData =
pseudocodeVariablesData.getVariableUseStatusData();
final String initPrefix = " INIT:";
final String usePrefix = " USE:";
final int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getInstructionsIncludingDeadCode(), variableInitializers);
String initPrefix = " INIT:";
String usePrefix = " USE:";
int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getInstructionsIncludingDeadCode(), variableInitializers);
dumpInstructions(pseudocode, out, new Function3<Instruction, Instruction, Instruction, String>() {
@Override
@@ -74,7 +74,7 @@ public class CFGraphToDotFilePrinter {
out.close();
}
private static void dumpEdges(List<Instruction> instructions, final PrintStream out, final int[] count, final Map<Instruction, String> nodeToName) {
private static void dumpEdges(List<Instruction> instructions, PrintStream out, int[] count, Map<Instruction, String> nodeToName) {
for (Instruction fromInst : instructions) {
fromInst.accept(new InstructionVisitor() {
@Override
@@ -59,7 +59,7 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testMissing() throws Exception {
final DiagnosticData typeMismatch1 = diagnostics.get(1);
DiagnosticData typeMismatch1 = diagnostics.get(1);
doTest(new TheTest(missing(typeMismatch1)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -69,7 +69,7 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testUnexpected() throws Exception {
final DiagnosticData typeMismatch1 = diagnostics.get(1);
DiagnosticData typeMismatch1 = diagnostics.get(1);
doTest(new TheTest(unexpected(typeMismatch1)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -79,8 +79,8 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testBoth() throws Exception {
final DiagnosticData typeMismatch1 = diagnostics.get(1);
final DiagnosticData unresolvedReference = diagnostics.get(6);
DiagnosticData typeMismatch1 = diagnostics.get(1);
DiagnosticData unresolvedReference = diagnostics.get(6);
doTest(new TheTest(unexpected(typeMismatch1), missing(unresolvedReference)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -91,8 +91,8 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testMissingInTheMiddle() throws Exception {
final DiagnosticData noneApplicable = diagnostics.get(4);
final DiagnosticData typeMismatch3 = diagnostics.get(5);
DiagnosticData noneApplicable = diagnostics.get(4);
DiagnosticData typeMismatch3 = diagnostics.get(5);
doTest(new TheTest(unexpected(noneApplicable), missing(typeMismatch3)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -103,9 +103,9 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testWrongParameters() throws Exception {
final DiagnosticData unused = diagnostics.get(2);
DiagnosticData unused = diagnostics.get(2);
String unusedDiagnostic = asTextDiagnostic(unused, "i");
final DiagnosedRange range = asDiagnosticRange(unused, unusedDiagnostic);
DiagnosedRange range = asDiagnosticRange(unused, unusedDiagnostic);
doTest(new TheTest(wrongParameters(unusedDiagnostic, "UNUSED_VARIABLE(a)", unused.startOffset, unused.endOffset)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -115,10 +115,10 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
}
public void testWrongParameterInMultiRange() throws Exception {
final DiagnosticData unresolvedReference = diagnostics.get(6);
DiagnosticData unresolvedReference = diagnostics.get(6);
String unusedDiagnostic = asTextDiagnostic(unresolvedReference, "i");
String toManyArguments = asTextDiagnostic(diagnostics.get(7));
final DiagnosedRange range = asDiagnosticRange(unresolvedReference, unusedDiagnostic, toManyArguments);
DiagnosedRange range = asDiagnosticRange(unresolvedReference, unusedDiagnostic, toManyArguments);
doTest(new TheTest(wrongParameters(unusedDiagnostic, "UNRESOLVED_REFERENCE(xx)", unresolvedReference.startOffset, unresolvedReference.endOffset)) {
@Override
protected void makeTestData(List<ActualDiagnostic> diagnostics, List<DiagnosedRange> diagnosedRanges) {
@@ -160,7 +160,7 @@ public class CheckerTestUtilTest extends KotlinTestWithEnvironment {
makeTestData(actualDiagnostics, diagnosedRanges);
List<String> expectedMessages = Lists.newArrayList(expected);
final List<String> actualMessages = Lists.newArrayList();
List<String> actualMessages = Lists.newArrayList();
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, actualDiagnostics, new CheckerTestUtil.DiagnosticDiffCallbacks() {
@Override
@@ -127,7 +127,7 @@ public abstract class AbstractCliTest extends TestCaseWithTmpdir {
}
@NotNull
static List<String> readArgs(@NotNull final String argsFilePath, @NotNull final String tempDir) throws IOException {
static List<String> readArgs(@NotNull String argsFilePath, @NotNull String tempDir) throws IOException {
List<String> lines = FilesKt.readLines(new File(argsFilePath), Charsets.UTF_8);
return CollectionsKt.mapNotNull(lines, new Function1<String, String>() {
@@ -233,7 +233,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
reader.accept(new ClassVisitor(Opcodes.ASM5) {
@Override
public MethodVisitor visitMethod(
int access, @NotNull final String callerName, @NotNull final String callerDesc, String signature, String[] exceptions
int access, @NotNull String callerName, @NotNull String callerDesc, String signature, String[] exceptions
) {
return new MethodVisitor(Opcodes.ASM5) {
@Override
@@ -119,7 +119,7 @@ public class InnerClassInfoGenTest extends CodegenTestCase {
private void checkAccess(@NotNull String outerName, @NotNull final String innerName, int accessFlags) {
private void checkAccess(@NotNull String outerName, @NotNull String innerName, int accessFlags) {
String name = outerName + "$" + innerName;
InnerClassAttribute attribute = CollectionsKt.single(extractInnerClasses(name),
new Function1<InnerClassAttribute, Boolean>() {
@@ -145,7 +145,7 @@ public class InnerClassInfoGenTest extends CodegenTestCase {
assertNotNull(outputFile);
byte[] bytes = outputFile.asByteArray();
ClassReader reader = new ClassReader(bytes);
final List<InnerClassAttribute> result = new ArrayList<InnerClassAttribute>();
List<InnerClassAttribute> result = new ArrayList<InnerClassAttribute>();
reader.accept(new ClassVisitor(ASM5) {
@Override
@@ -218,7 +218,7 @@ public class OuterClassGenTest extends CodegenTestCase {
@Nullable
private static OuterClassInfo readOuterClassInfo(@NotNull ClassReader reader) {
final Ref<OuterClassInfo> info = Ref.create();
Ref<OuterClassInfo> info = Ref.create();
reader.accept(new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
@@ -43,7 +43,7 @@ public class SourceInfoGenTest extends CodegenTestCase {
ClassReader classReader = new ClassReader(file.asByteArray());
final String [] producer = new String[1];
String[] producer = new String[1];
classReader.accept(new ClassVisitor(Opcodes.ASM5) {
@Override
@@ -288,10 +288,10 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
private void doTestKotlinLibraryWithWrongMetadataVersion(
@NotNull String libraryName,
@Nullable final Function2<String, Object, Object> additionalTransformation,
@Nullable Function2<String, Object, Object> additionalTransformation,
@NotNull String... additionalOptions
) throws Exception {
final int[] version = new JvmMetadataVersion(42, 0, 0).toArray();
int[] version = new JvmMetadataVersion(42, 0, 0).toArray();
File library = transformJar(compileLibrary(libraryName), new Function2<String, byte[], byte[]>() {
@Override
public byte[] invoke(String name, byte[] bytes) {
@@ -570,7 +570,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
compileKotlin("source.kt", tmpdir, tmpdir);
final Ref<String> debugInfo = new Ref<String>();
Ref<String> debugInfo = new Ref<String>();
File resultFile = new File(tmpdir.getAbsolutePath(), "test/B.class");
new ClassReader(FilesKt.readBytes(resultFile)).accept(new ClassVisitor(Opcodes.ASM5) {
@Override
@@ -644,8 +644,8 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
}
public void testInnerClassPackageConflict2() throws Exception {
final File library1 = compileJava("library1");
final File library2 = compileJava("library2");
File library1 = compileJava("library1");
File library2 = compileJava("library2");
// Copy everything from library2 to library1
FileUtil.visitFiles(library2, new Processor<File>() {
@@ -297,7 +297,7 @@ public class StorageManagerTest extends TestCase {
}
public void testRecursionToleranceAndPostCompute() throws Exception {
final CounterImpl counter = new CounterImpl();
CounterImpl counter = new CounterImpl();
class C {
NotNullLazyValue<String> rec = m.createLazyValueWithPostCompute(
new Function0<String>() {
@@ -330,7 +330,7 @@ public class StorageManagerTest extends TestCase {
}
public void testPostComputeNoRecursion() throws Exception {
final CounterImpl counter = new CounterImpl();
CounterImpl counter = new CounterImpl();
NotNullLazyValue<Collection<String>> v = m.createLazyValueWithPostCompute(
new Function0<Collection<String>>() {
@Override
@@ -357,7 +357,7 @@ public class StorageManagerTest extends TestCase {
}
public void testNullablePostComputeNoRecursion() throws Exception {
final CounterImpl counter = new CounterImpl();
CounterImpl counter = new CounterImpl();
NullableLazyValue<Collection<String>> v = m.createNullableLazyValueWithPostCompute(
new Function0<Collection<String>>() {
@Override
@@ -424,7 +424,7 @@ public class StorageManagerTest extends TestCase {
}
public void testFallThrough() throws Exception {
final CounterImpl c = new CounterImpl();
CounterImpl c = new CounterImpl();
class C {
NotNullLazyValue<Integer> rec = LockBasedStorageManager.NO_LOCKS.createLazyValue(new Function0<Integer>() {
@Override
@@ -500,7 +500,7 @@ public class StorageManagerTest extends TestCase {
// Utilities
private static <K, V> Function0<V> apply(final Function1<K, V> f, final K x) {
private static <K, V> Function0<V> apply(Function1<K, V> f, K x) {
return new Function0<V>() {
@Override
public V invoke() {
@@ -77,7 +77,7 @@ public class RecursiveDescriptorProcessorTest extends KotlinTestWithEnvironment
}
private static List<String> recursivelyCollectDescriptors(PackageViewDescriptor testPackage) {
final List<String> lines = Lists.newArrayList();
List<String> lines = Lists.newArrayList();
RecursiveDescriptorProcessor.process(testPackage, null, new DeclarationDescriptorVisitor<Boolean, Void>() {
private void add(DeclarationDescriptor descriptor) {
@@ -90,7 +90,7 @@ public class DefaultModalityModifiersTest extends KotlinTestWithEnvironment {
KtDeclaration aClass = file.getDeclarations().get(0);
assert aClass instanceof KtClass;
AnalysisResult bindingContext = JvmResolveUtil.analyzeAndCheckForErrors(file, getEnvironment());
final DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
return new LexicalScopeImpl(ScopeUtilsKt.memberScopeAsImportingScope(libraryScope), root, false, null,
LexicalScopeKind.SYNTHETIC, LocalRedeclarationChecker.DO_NOTHING.INSTANCE,
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@@ -88,7 +88,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
ModuleDescriptor module = analysisResult.getModuleDescriptor();
LexicalScope topLevelScope = analysisResult.getBindingContext().get(BindingContext.LEXICAL_SCOPE, ktFile);
final ClassifierDescriptor contextClass =
ClassifierDescriptor contextClass =
ScopeUtilsKt.findClassifier(topLevelScope, Name.identifier("___Context"), NoLookupLocation.FROM_TEST);
assert contextClass instanceof ClassDescriptor;
LocalRedeclarationChecker redeclarationChecker =