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() {