From fba329d6d51220f9e70c0c24919a84379772d5c0 Mon Sep 17 00:00:00 2001 From: Max Cai Date: Wed, 16 Oct 2013 16:26:50 +0100 Subject: Feature request: set() and clear() accessors return this Also pre-inlines set() and has() in serialization code. This could theoretically help ProGuard: the message class size is usually large, and because of this only, it may refuse to inline an accessor into the serialization code, and as a result keeps the accessor intact. Chances are, after pre-inlining all accessor calls within the message class, those accessors become unused or single-use, so there are more reasons for ProGuard to inline and then remove them. Change-Id: I57decbe0b2533c1be21439de0aad15f49c7024dd --- java/src/test/java/com/google/protobuf/NanoTest.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'java') diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index d4e9dfcb..1149c40b 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -2322,6 +2322,12 @@ public class NanoTest extends TestCase { assertFalse(msg.hasOptionalString()); assertFalse(msg.hasDefaultString()); assertFalse(msg.hasBitFieldCheck()); + + // Test set() and clear() returns itself (compiles = success) + msg.clear() + .setOptionalInt32(3) + .clearDefaultBytes() + .setOptionalString("4"); } public void testNanoWithAccessorsParseFrom() throws Exception { -- cgit v1.2.3