Disable MemberValuePropagation when -dontoptimize.
Bug: 36800551, 68292416
Change-Id: I28f99c8f8eb037ac28894c9befbc3e68ea6aff58
diff --git a/src/test/examples/write_only_field/WriteOnlyCls.java b/src/test/examples/write_only_field/WriteOnlyCls.java
new file mode 100644
index 0000000..b68e4aa
--- /dev/null
+++ b/src/test/examples/write_only_field/WriteOnlyCls.java
@@ -0,0 +1,27 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package write_only_field;
+
+public class WriteOnlyCls {
+
+ static class DataObj {
+ final int f1;
+ DataObj(int f1) {
+ this.f1 = f1;
+ }
+ }
+
+ static DataObj static_field = new DataObj(1);
+
+ DataObj instance_field;
+
+ public WriteOnlyCls(int n) {
+ instance_field = new DataObj(n);
+ }
+
+ public static void main(String[] args) {
+ WriteOnlyCls instance = new WriteOnlyCls(2);
+ }
+
+}
diff --git a/src/test/examples/write_only_field/keep-rules-dontoptimize.txt b/src/test/examples/write_only_field/keep-rules-dontoptimize.txt
new file mode 100644
index 0000000..34957b1
--- /dev/null
+++ b/src/test/examples/write_only_field/keep-rules-dontoptimize.txt
@@ -0,0 +1,11 @@
+# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# Keep the application entry point. Get rid of everything that is not
+# reachable from there.
+-keep public class write_only_field.WriteOnlyCls {
+ public static void main(...);
+}
+
+-dontoptimize
diff --git a/src/test/examples/write_only_field/keep-rules.txt b/src/test/examples/write_only_field/keep-rules.txt
new file mode 100644
index 0000000..3cc9314
--- /dev/null
+++ b/src/test/examples/write_only_field/keep-rules.txt
@@ -0,0 +1,9 @@
+# Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# Keep the application entry point. Get rid of everything that is not
+# reachable from there.
+-keep public class write_only_field.WriteOnlyCls {
+ public static void main(...);
+}