aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikaël Peltier <mikaelpeltier@google.com>2017-10-19 11:58:34 +0200
committerMikaël Peltier <mikaelpeltier@google.com>2017-10-19 11:58:34 +0200
commit75b182e177c4c3c278b1e3920eb11d17e5f3b4b7 (patch)
tree3551828943a9066bc228400b2c7ae0243ccae502
parente2c1a9e3b0fcd30fba8e28870debadb276010aa4 (diff)
downloadr8-75b182e177c4c3c278b1e3920eb11d17e5f3b4b7.tar.gz
Enable OvershadowingSubclassFields checker
- Overshadowing fields of superclass can causes confusion and errors and is probably a good thing to avoid it. Change-Id: If73e4694ba57bf048495650b047f1943c9a5e3b1
-rw-r--r--build.gradle3
-rw-r--r--src/main/java/com/android/tools/r8/ir/optimize/Outliner.java3
-rw-r--r--src/main/java/com/android/tools/r8/shaking/protolite/ProtoLitePruner.java9
3 files changed, 6 insertions, 9 deletions
diff --git a/build.gradle b/build.gradle
index e50073dc8..6dadb5c87 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,7 +18,8 @@ def errorProneConfiguration = [
'-Xep:ClassCanBeStatic:WARN',
'-Xep:OperatorPrecedence:WARN',
'-Xep:RemoveUnusedImports:WARN',
- '-Xep:MissingOverride:WARN']
+ '-Xep:MissingOverride:WARN',
+ '-Xep:OvershadowingSubclassFields:WARN']
apply from: 'copyAdditionalJctfCommonFiles.gradle'
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
index 9385f1138..74afdcd14 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
@@ -685,7 +685,6 @@ public class Outliner {
private final ListIterator<BasicBlock> blocksIterator;
private final List<Integer> toRemove;
int argumentsMapIndex;
- Value returnValue;
OutlineRewriter(
DexEncodedMethod method, IRCode code,
@@ -702,7 +701,7 @@ public class Outliner {
DexMethod m = generatedOutlines.get(outline);
assert m != null;
List<Value> in = new ArrayList<>();
- returnValue = null;
+ Value returnValue = null;
argumentsMapIndex = 0;
Position position = Position.none();
{ // Scope for 'instructions'.
diff --git a/src/main/java/com/android/tools/r8/shaking/protolite/ProtoLitePruner.java b/src/main/java/com/android/tools/r8/shaking/protolite/ProtoLitePruner.java
index 7773e1134..ced15f527 100644
--- a/src/main/java/com/android/tools/r8/shaking/protolite/ProtoLitePruner.java
+++ b/src/main/java/com/android/tools/r8/shaking/protolite/ProtoLitePruner.java
@@ -53,8 +53,6 @@ import java.util.function.BiPredicate;
*/
public class ProtoLitePruner extends ProtoLiteBase {
- private final AppInfoWithLiveness appInfo;
-
private final DexType visitorType;
private final DexType methodEnumType;
@@ -77,7 +75,6 @@ public class ProtoLitePruner extends ProtoLiteBase {
public ProtoLitePruner(AppInfoWithLiveness appInfo) {
super(appInfo);
- this.appInfo = appInfo;
DexItemFactory factory = appInfo.dexItemFactory;
this.visitorType = factory.createType("Lcom/google/protobuf/GeneratedMessageLite$Visitor;");
this.methodEnumType = factory
@@ -318,7 +315,7 @@ public class ProtoLitePruner extends ProtoLiteBase {
throw new CompilationError("dynamicMethod in protoLite without switch.");
}
Switch switchInstr = matchingInstr.asSwitch();
- EnumSwitchInfo info = SwitchUtils.analyzeSwitchOverEnum(switchInstr, appInfo);
+ EnumSwitchInfo info = SwitchUtils.analyzeSwitchOverEnum(switchInstr, appInfo.withLiveness());
if (info == null || info.enumClass != methodEnumType) {
throw new CompilationError("Malformed switch in dynamicMethod of proto lite.");
}
@@ -471,7 +468,7 @@ public class ProtoLitePruner extends ProtoLiteBase {
// We have to rewrite these as a precaution, as they might be dead due to
// tree shaking ignoring them.
DexField field = getterToField(invokedMethod, 5);
- if (appInfo.liveFields.contains(field)) {
+ if (appInfo.withLiveness().liveFields.contains(field)) {
// Effectively inline the code that is normally inside these methods.
Value thisReference = invokeMethod.getReceiver();
Value newResult = code.createValue(MoveType.SINGLE);
@@ -658,7 +655,7 @@ public class ProtoLitePruner extends ProtoLiteBase {
}
private boolean isDeadProtoField(DexField field) {
- return isProtoField(field) && !appInfo.liveFields.contains(field);
+ return isProtoField(field) && !appInfo.withLiveness().liveFields.contains(field);
}
private boolean isDeadProtoGetter(DexMethod method) {