From 60cf071ee1f3d2e2cb34d5ed4892dd2f56ccad48 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Fri, 8 May 2026 14:06:35 +0200 Subject: [PATCH 01/11] Make `create()` functions have `GeneratedMessage Function()` type Often apps use extensive numbers of protos. The `BuilderInfo` of a proto will refer to sub proto messages via using `Foo.create` tear-offs. Big apps can end up with tens of thousands of those `.create` closures. All of them currently have a unique ` Function()` function type. Though the actual usage of those closures is only in contexts where the caller of the closure expects a `GeneratedMessage` as return type. If a caller knew the actual return type, then the caller could call the constructor directly. To avoid having to create potentially tens of thousands of unique function types, we make those closures have the `GeneratedMessage Function()` type. --- benchmarks/bin/from_proto3_json_object.dart | 6 +- benchmarks/bin/from_proto3_json_string.dart | 6 +- protobuf/lib/src/protobuf/builder_info.dart | 6 +- .../lib/src/protobuf/generated_message.dart | 15 +- .../google/protobuf/any.pb.dart | 12 +- .../google/protobuf/api.pb.dart | 30 +- .../google/protobuf/duration.pb.dart | 10 +- .../google/protobuf/empty.pb.dart | 10 +- .../google/protobuf/field_mask.pb.dart | 10 +- .../google/protobuf/source_context.pb.dart | 10 +- .../google/protobuf/struct.pb.dart | 30 +- .../google/protobuf/timestamp.pb.dart | 12 +- .../google/protobuf/type.pb.dart | 50 +-- .../google/protobuf/wrappers.pb.dart | 90 ++--- protobuf/test/readonly_message_test.dart | 44 +-- .../lib/src/gen/dart_options.pb.dart | 20 +- .../lib/src/gen/google/api/client.pb.dart | 150 ++++---- .../lib/src/gen/google/api/http.pb.dart | 30 +- .../lib/src/gen/google/api/routing.pb.dart | 20 +- .../google/protobuf/compiler/plugin.pb.dart | 40 +-- .../gen/google/protobuf/descriptor.pb.dart | 340 +++++++++--------- .../google/protobuf/unittest_features.pb.dart | 30 +- protoc_plugin/lib/src/message_generator.dart | 14 +- .../test/goldens/deprecations.pb.dart | 20 +- .../test/goldens/doc_comments.pb.dart | 20 +- protoc_plugin/test/goldens/extension.pb.dart | 15 +- .../test/goldens/grpc_service.pb.dart | 10 +- protoc_plugin/test/goldens/imports.pb.dart | 10 +- protoc_plugin/test/goldens/int64.pb.dart | 10 +- .../test/goldens/messageGenerator.pb.dart | 10 +- protoc_plugin/test/goldens/oneMessage.pb.dart | 10 +- protoc_plugin/test/goldens/service.pb.dart | 10 +- protoc_plugin/test/map_field_test.dart | 4 +- 33 files changed, 558 insertions(+), 546 deletions(-) diff --git a/benchmarks/bin/from_proto3_json_object.dart b/benchmarks/bin/from_proto3_json_object.dart index f39a2dbb9..5f3b20626 100644 --- a/benchmarks/bin/from_proto3_json_object.dart +++ b/benchmarks/bin/from_proto3_json_object.dart @@ -35,13 +35,13 @@ class Benchmark extends BenchmarkBase { @override void run() { sink1 = - p2.GoogleMessage1.create() + p2.GoogleMessage1() ..mergeFromProto3Json(_message1Proto2Proto3JsonObject); sink2 = - p3.GoogleMessage1.create() + p3.GoogleMessage1() ..mergeFromProto3Json(_message1Proto3Proto3JsonObject); sink3 = - GoogleMessage2.create()..mergeFromProto3Json(_message2Proto3JsonObject); + GoogleMessage2()..mergeFromProto3Json(_message2Proto3JsonObject); } } diff --git a/benchmarks/bin/from_proto3_json_string.dart b/benchmarks/bin/from_proto3_json_string.dart index 84afb98cc..51987886d 100644 --- a/benchmarks/bin/from_proto3_json_string.dart +++ b/benchmarks/bin/from_proto3_json_string.dart @@ -40,13 +40,13 @@ class Benchmark extends BenchmarkBase { @override void run() { sink1 = - p2.GoogleMessage1.create() + p2.GoogleMessage1() ..mergeFromProto3Json(jsonDecode(_message1Proto2Proto3JsonString)); sink2 = - p3.GoogleMessage1.create() + p3.GoogleMessage1() ..mergeFromProto3Json(jsonDecode(_message1Proto3Proto3JsonString)); sink3 = - GoogleMessage2.create() + GoogleMessage2() ..mergeFromProto3Json(jsonDecode(_message2Proto3JsonString)); } } diff --git a/protobuf/lib/src/protobuf/builder_info.dart b/protobuf/lib/src/protobuf/builder_info.dart index 28997e4c2..b98c685cf 100644 --- a/protobuf/lib/src/protobuf/builder_info.dart +++ b/protobuf/lib/src/protobuf/builder_info.dart @@ -411,7 +411,7 @@ class BuilderInfo { void aOM( int tagNumber, String name, { - required T Function() subBuilder, + required GeneratedMessage Function() subBuilder, String? protoName, }) { add( @@ -430,7 +430,7 @@ class BuilderInfo { void aQM( int tagNumber, String name, { - required T Function() subBuilder, + required GeneratedMessage Function() subBuilder, String? protoName, }) { add( @@ -449,7 +449,7 @@ class BuilderInfo { void pPM( int tagNumber, String name, { - required T Function() subBuilder, + required GeneratedMessage Function() subBuilder, String? protoName, }) { addRepeated( diff --git a/protobuf/lib/src/protobuf/generated_message.dart b/protobuf/lib/src/protobuf/generated_message.dart index acfe9f802..b27f91cde 100644 --- a/protobuf/lib/src/protobuf/generated_message.dart +++ b/protobuf/lib/src/protobuf/generated_message.dart @@ -544,16 +544,17 @@ abstract class GeneratedMessage { _defaultMakers = {}; static T Function() _defaultMakerFor( - T Function()? createFn, - ) => _getSingletonMaker(createFn!)._frozenSingletonCreator; + GeneratedMessage Function()? createFn, + ) => _getSingletonMaker(createFn!)._frozenSingletonCreator; /// For generated code only. /// @nodoc - static T $_defaultFor(T Function() createFn) => - _getSingletonMaker(createFn)._frozenSingleton; + static T $_defaultFor( + GeneratedMessage Function() createFn, + ) => _getSingletonMaker(createFn)._frozenSingleton; static _SingletonMaker _getSingletonMaker( - T Function() fun, + GeneratedMessage Function() fun, ) { final oldMaker = _defaultMakers[fun]; if (oldMaker != null) { @@ -571,11 +572,11 @@ abstract class GeneratedMessage { // A downcast to a generic interface type is much easier to perform at runtime // than a downcast to a generic function type. class _SingletonMaker { - final T Function() _creator; + final GeneratedMessage Function() _creator; _SingletonMaker(this._creator); - late final T _frozenSingleton = _creator()..freeze(); + late final T _frozenSingleton = (_creator() as T)..freeze(); // ignore: prefer_function_declarations_over_variables late final T Function() _frozenSingletonCreator = () => _frozenSingleton; } diff --git a/protobuf/lib/well_known_types/google/protobuf/any.pb.dart b/protobuf/lib/well_known_types/google/protobuf/any.pb.dart index 2623677c1..ec10be5cf 100644 --- a/protobuf/lib/well_known_types/google/protobuf/any.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/any.pb.dart @@ -108,7 +108,7 @@ class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { $core.String? typeUrl, $core.List<$core.int>? value, }) { - final result = create(); + final result = Any._(); if (typeUrl != null) result.typeUrl = typeUrl; if (value != null) result.value = value; return result; @@ -118,10 +118,10 @@ class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { factory Any.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Any._()..mergeFromBuffer(data, registry); factory Any.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Any._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Any', @@ -144,9 +144,9 @@ class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Any create() => Any._(); + static $pb.GeneratedMessage create() => Any._(); @$core.override - Any createEmptyInstance() => create(); + Any createEmptyInstance() => Any._(); @$core.pragma('dart2js:noInline') static Any getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -205,7 +205,7 @@ class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { /// the fully qualified name of the type of [message]. static Any pack($pb.GeneratedMessage message, {$core.String typeUrlPrefix = 'type.googleapis.com'}) { - final result = create(); + final result = Any._(); $mixin.AnyMixin.packIntoAny(result, message, typeUrlPrefix: typeUrlPrefix); return result; } diff --git a/protobuf/lib/well_known_types/google/protobuf/api.pb.dart b/protobuf/lib/well_known_types/google/protobuf/api.pb.dart index b2761060a..1e62c5d17 100644 --- a/protobuf/lib/well_known_types/google/protobuf/api.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/api.pb.dart @@ -44,7 +44,7 @@ class Api extends $pb.GeneratedMessage { $0.Syntax? syntax, $core.String? edition, }) { - final result = create(); + final result = Api._(); if (name != null) result.name = name; if (methods != null) result.methods.addAll(methods); if (options != null) result.options.addAll(options); @@ -60,10 +60,10 @@ class Api extends $pb.GeneratedMessage { factory Api.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Api._()..mergeFromBuffer(data, registry); factory Api.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Api._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Api', @@ -94,9 +94,9 @@ class Api extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Api create() => Api._(); + static $pb.GeneratedMessage create() => Api._(); @$core.override - Api createEmptyInstance() => create(); + Api createEmptyInstance() => Api._(); @$core.pragma('dart2js:noInline') static Api getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -204,7 +204,7 @@ class Method extends $pb.GeneratedMessage { @$core.Deprecated('This field is deprecated.') $0.Syntax? syntax, @$core.Deprecated('This field is deprecated.') $core.String? edition, }) { - final result = create(); + final result = Method._(); if (name != null) result.name = name; if (requestTypeUrl != null) result.requestTypeUrl = requestTypeUrl; if (requestStreaming != null) result.requestStreaming = requestStreaming; @@ -220,10 +220,10 @@ class Method extends $pb.GeneratedMessage { factory Method.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Method._()..mergeFromBuffer(data, registry); factory Method.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Method._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Method', @@ -252,9 +252,9 @@ class Method extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Method create() => Method._(); + static $pb.GeneratedMessage create() => Method._(); @$core.override - Method createEmptyInstance() => create(); + Method createEmptyInstance() => Method._(); @$core.pragma('dart2js:noInline') static Method getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -432,7 +432,7 @@ class Mixin extends $pb.GeneratedMessage { $core.String? name, $core.String? root, }) { - final result = create(); + final result = Mixin._(); if (name != null) result.name = name; if (root != null) result.root = root; return result; @@ -442,10 +442,10 @@ class Mixin extends $pb.GeneratedMessage { factory Mixin.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Mixin._()..mergeFromBuffer(data, registry); factory Mixin.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Mixin._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Mixin', @@ -466,9 +466,9 @@ class Mixin extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Mixin create() => Mixin._(); + static $pb.GeneratedMessage create() => Mixin._(); @$core.override - Mixin createEmptyInstance() => create(); + Mixin createEmptyInstance() => Mixin._(); @$core.pragma('dart2js:noInline') static Mixin getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/duration.pb.dart b/protobuf/lib/well_known_types/google/protobuf/duration.pb.dart index 1d2be314c..9ab922fa8 100644 --- a/protobuf/lib/well_known_types/google/protobuf/duration.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/duration.pb.dart @@ -82,7 +82,7 @@ class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { $fixnum.Int64? seconds, $core.int? nanos, }) { - final result = create(); + final result = Duration._(); if (seconds != null) result.seconds = seconds; if (nanos != null) result.nanos = nanos; return result; @@ -92,10 +92,10 @@ class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { factory Duration.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Duration._()..mergeFromBuffer(data, registry); factory Duration.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Duration._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Duration', @@ -117,9 +117,9 @@ class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Duration create() => Duration._(); + static $pb.GeneratedMessage create() => Duration._(); @$core.override - Duration createEmptyInstance() => create(); + Duration createEmptyInstance() => Duration._(); @$core.pragma('dart2js:noInline') static Duration getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/empty.pb.dart b/protobuf/lib/well_known_types/google/protobuf/empty.pb.dart index 8c77bb7d1..370a373c3 100644 --- a/protobuf/lib/well_known_types/google/protobuf/empty.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/empty.pb.dart @@ -24,16 +24,16 @@ export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; /// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); /// } class Empty extends $pb.GeneratedMessage { - factory Empty() => create(); + factory Empty() => Empty._(); Empty._(); factory Empty.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Empty._()..mergeFromBuffer(data, registry); factory Empty.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Empty._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Empty', @@ -52,9 +52,9 @@ class Empty extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Empty create() => Empty._(); + static $pb.GeneratedMessage create() => Empty._(); @$core.override - Empty createEmptyInstance() => create(); + Empty createEmptyInstance() => Empty._(); @$core.pragma('dart2js:noInline') static Empty getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/field_mask.pb.dart b/protobuf/lib/well_known_types/google/protobuf/field_mask.pb.dart index a41c1e730..aeed34516 100644 --- a/protobuf/lib/well_known_types/google/protobuf/field_mask.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/field_mask.pb.dart @@ -221,7 +221,7 @@ class FieldMask extends $pb.GeneratedMessage with $mixin.FieldMaskMixin { factory FieldMask({ $core.Iterable<$core.String>? paths, }) { - final result = create(); + final result = FieldMask._(); if (paths != null) result.paths.addAll(paths); return result; } @@ -230,10 +230,10 @@ class FieldMask extends $pb.GeneratedMessage with $mixin.FieldMaskMixin { factory FieldMask.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + FieldMask._()..mergeFromBuffer(data, registry); factory FieldMask.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + FieldMask._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'FieldMask', @@ -254,9 +254,9 @@ class FieldMask extends $pb.GeneratedMessage with $mixin.FieldMaskMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static FieldMask create() => FieldMask._(); + static $pb.GeneratedMessage create() => FieldMask._(); @$core.override - FieldMask createEmptyInstance() => create(); + FieldMask createEmptyInstance() => FieldMask._(); @$core.pragma('dart2js:noInline') static FieldMask getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/source_context.pb.dart b/protobuf/lib/well_known_types/google/protobuf/source_context.pb.dart index b2663260f..ba5092a50 100644 --- a/protobuf/lib/well_known_types/google/protobuf/source_context.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/source_context.pb.dart @@ -22,7 +22,7 @@ class SourceContext extends $pb.GeneratedMessage { factory SourceContext({ $core.String? fileName, }) { - final result = create(); + final result = SourceContext._(); if (fileName != null) result.fileName = fileName; return result; } @@ -31,10 +31,10 @@ class SourceContext extends $pb.GeneratedMessage { factory SourceContext.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + SourceContext._()..mergeFromBuffer(data, registry); factory SourceContext.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + SourceContext._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'SourceContext', @@ -55,9 +55,9 @@ class SourceContext extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static SourceContext create() => SourceContext._(); + static $pb.GeneratedMessage create() => SourceContext._(); @$core.override - SourceContext createEmptyInstance() => create(); + SourceContext createEmptyInstance() => SourceContext._(); @$core.pragma('dart2js:noInline') static SourceContext getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/struct.pb.dart b/protobuf/lib/well_known_types/google/protobuf/struct.pb.dart index ba3ba129d..a9abf6212 100644 --- a/protobuf/lib/well_known_types/google/protobuf/struct.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/struct.pb.dart @@ -32,7 +32,7 @@ class Struct extends $pb.GeneratedMessage with $mixin.StructMixin { factory Struct({ $core.Iterable<$core.MapEntry<$core.String, Value>>? fields, }) { - final result = create(); + final result = Struct._(); if (fields != null) result.fields.addEntries(fields); return result; } @@ -41,10 +41,10 @@ class Struct extends $pb.GeneratedMessage with $mixin.StructMixin { factory Struct.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Struct._()..mergeFromBuffer(data, registry); factory Struct.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Struct._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Struct', @@ -71,9 +71,9 @@ class Struct extends $pb.GeneratedMessage with $mixin.StructMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Struct create() => Struct._(); + static $pb.GeneratedMessage create() => Struct._(); @$core.override - Struct createEmptyInstance() => create(); + Struct createEmptyInstance() => Struct._(); @$core.pragma('dart2js:noInline') static Struct getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -109,7 +109,7 @@ class Value extends $pb.GeneratedMessage with $mixin.ValueMixin { Struct? structValue, ListValue? listValue, }) { - final result = create(); + final result = Value._(); if (nullValue != null) result.nullValue = nullValue; if (numberValue != null) result.numberValue = numberValue; if (stringValue != null) result.stringValue = stringValue; @@ -123,10 +123,10 @@ class Value extends $pb.GeneratedMessage with $mixin.ValueMixin { factory Value.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Value._()..mergeFromBuffer(data, registry); factory Value.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Value._()..mergeFromJson(json, registry); static const $core.Map<$core.int, Value_Kind> _Value_KindByTag = { 1: Value_Kind.nullValue, @@ -165,9 +165,9 @@ class Value extends $pb.GeneratedMessage with $mixin.ValueMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Value create() => Value._(); + static $pb.GeneratedMessage create() => Value._(); @$core.override - Value createEmptyInstance() => create(); + Value createEmptyInstance() => Value._(); @$core.pragma('dart2js:noInline') static Value getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -260,7 +260,7 @@ class ListValue extends $pb.GeneratedMessage with $mixin.ListValueMixin { factory ListValue({ $core.Iterable? values, }) { - final result = create(); + final result = ListValue._(); if (values != null) result.values.addAll(values); return result; } @@ -269,10 +269,10 @@ class ListValue extends $pb.GeneratedMessage with $mixin.ListValueMixin { factory ListValue.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + ListValue._()..mergeFromBuffer(data, registry); factory ListValue.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + ListValue._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'ListValue', @@ -293,9 +293,9 @@ class ListValue extends $pb.GeneratedMessage with $mixin.ListValueMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static ListValue create() => ListValue._(); + static $pb.GeneratedMessage create() => ListValue._(); @$core.override - ListValue createEmptyInstance() => create(); + ListValue createEmptyInstance() => ListValue._(); @$core.pragma('dart2js:noInline') static ListValue getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); diff --git a/protobuf/lib/well_known_types/google/protobuf/timestamp.pb.dart b/protobuf/lib/well_known_types/google/protobuf/timestamp.pb.dart index 0df118ca2..cf4b12846 100644 --- a/protobuf/lib/well_known_types/google/protobuf/timestamp.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/timestamp.pb.dart @@ -113,7 +113,7 @@ class Timestamp extends $pb.GeneratedMessage with $mixin.TimestampMixin { $fixnum.Int64? seconds, $core.int? nanos, }) { - final result = create(); + final result = Timestamp._(); if (seconds != null) result.seconds = seconds; if (nanos != null) result.nanos = nanos; return result; @@ -123,10 +123,10 @@ class Timestamp extends $pb.GeneratedMessage with $mixin.TimestampMixin { factory Timestamp.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Timestamp._()..mergeFromBuffer(data, registry); factory Timestamp.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Timestamp._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Timestamp', @@ -148,9 +148,9 @@ class Timestamp extends $pb.GeneratedMessage with $mixin.TimestampMixin { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Timestamp create() => Timestamp._(); + static $pb.GeneratedMessage create() => Timestamp._(); @$core.override - Timestamp createEmptyInstance() => create(); + Timestamp createEmptyInstance() => Timestamp._(); @$core.pragma('dart2js:noInline') static Timestamp getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -186,7 +186,7 @@ class Timestamp extends $pb.GeneratedMessage with $mixin.TimestampMixin { /// /// Time zone information will not be preserved. static Timestamp fromDateTime($core.DateTime dateTime) { - final result = create(); + final result = Timestamp._(); $mixin.TimestampMixin.setFromDateTime(result, dateTime); return result; } diff --git a/protobuf/lib/well_known_types/google/protobuf/type.pb.dart b/protobuf/lib/well_known_types/google/protobuf/type.pb.dart index 020580e62..27e2df9e3 100644 --- a/protobuf/lib/well_known_types/google/protobuf/type.pb.dart +++ b/protobuf/lib/well_known_types/google/protobuf/type.pb.dart @@ -37,7 +37,7 @@ class Type extends $pb.GeneratedMessage { Syntax? syntax, $core.String? edition, }) { - final result = create(); + final result = Type._(); if (name != null) result.name = name; if (fields != null) result.fields.addAll(fields); if (oneofs != null) result.oneofs.addAll(oneofs); @@ -52,10 +52,10 @@ class Type extends $pb.GeneratedMessage { factory Type.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Type._()..mergeFromBuffer(data, registry); factory Type.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Type._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Type', @@ -83,9 +83,9 @@ class Type extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Type create() => Type._(); + static $pb.GeneratedMessage create() => Type._(); @$core.override - Type createEmptyInstance() => create(); + Type createEmptyInstance() => Type._(); @$core.pragma('dart2js:noInline') static Type getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -165,7 +165,7 @@ class Field extends $pb.GeneratedMessage { $core.String? jsonName, $core.String? defaultValue, }) { - final result = create(); + final result = Field._(); if (kind != null) result.kind = kind; if (cardinality != null) result.cardinality = cardinality; if (number != null) result.number = number; @@ -183,10 +183,10 @@ class Field extends $pb.GeneratedMessage { factory Field.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Field._()..mergeFromBuffer(data, registry); factory Field.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Field._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Field', @@ -218,9 +218,9 @@ class Field extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Field create() => Field._(); + static $pb.GeneratedMessage create() => Field._(); @$core.override - Field createEmptyInstance() => create(); + Field createEmptyInstance() => Field._(); @$core.pragma('dart2js:noInline') static Field getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -338,7 +338,7 @@ class Enum extends $pb.GeneratedMessage { Syntax? syntax, $core.String? edition, }) { - final result = create(); + final result = Enum._(); if (name != null) result.name = name; if (enumvalue != null) result.enumvalue.addAll(enumvalue); if (options != null) result.options.addAll(options); @@ -352,10 +352,10 @@ class Enum extends $pb.GeneratedMessage { factory Enum.fromBuffer($core.List<$core.int> data, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(data, registry); + Enum._()..mergeFromBuffer(data, registry); factory Enum.fromJson($core.String json, [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(json, registry); + Enum._()..mergeFromJson(json, registry); static final $pb.BuilderInfo _i = $pb.BuilderInfo( _omitMessageNames ? '' : 'Enum', @@ -383,9 +383,9 @@ class Enum extends $pb.GeneratedMessage { $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static Enum create() => Enum._(); + static $pb.GeneratedMessage create() => Enum._(); @$core.override - Enum createEmptyInstance() => create(); + Enum createEmptyInstance() => Enum._(); @$core.pragma('dart2js:noInline') static Enum getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -454,7 +454,7 @@ class EnumValue extends $pb.GeneratedMessage { $core.int? number, $core.Iterable