From f9d8a67e372eb281cf682309fa4a612360fba410 Mon Sep 17 00:00:00 2001 From: Brian Slesinsky Date: Tue, 27 Oct 2015 14:35:06 -0700 Subject: [PATCH] Add declaration of clone() method (The protoc plugin automatically generates it.) BUG=https://github.com/dart-lang/dart-protobuf/issues/26 R=sgjesse@google.com Review URL: https://chromiumcodereview.appspot.com//1425873002. --- lib/meta.dart | 1 + lib/src/protobuf/generated_message.dart | 4 ++++ test/readonly_message_test.dart | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lib/meta.dart b/lib/meta.dart index 8547ffb32..8d16e62a8 100644 --- a/lib/meta.dart +++ b/lib/meta.dart @@ -48,6 +48,7 @@ const List GeneratedMessage_reservedNames = const [ 'eventPlugin', 'createRepeatedField', 'unknownFields', + 'clone', r'$_get', r'$_has', r'$_setBool', diff --git a/lib/src/protobuf/generated_message.dart b/lib/src/protobuf/generated_message.dart index 8cfd5f66f..ce254d115 100644 --- a/lib/src/protobuf/generated_message.dart +++ b/lib/src/protobuf/generated_message.dart @@ -44,6 +44,10 @@ abstract class GeneratedMessage { /// to protobuf fields. EventPlugin get eventPlugin => null; + /// Creates a deep copy of the fields in this message. + /// (The generated code uses [mergeFromMessage].) + GeneratedMessage clone(); + UnknownFieldSet get unknownFields => _fieldSet._ensureUnknownFields(); bool get _isReadOnly => false; diff --git a/test/readonly_message_test.dart b/test/readonly_message_test.dart index c6f11f4eb..5cbad018f 100644 --- a/test/readonly_message_test.dart +++ b/test/readonly_message_test.dart @@ -20,6 +20,8 @@ throwsError(Type expectedType, String expectedMessage) => throwsA( class Rec extends GeneratedMessage with ReadonlyMessageMixin { @override BuilderInfo info_ = new BuilderInfo("rec"); + @override + clone() => throw new UnimplementedError(); } main() {