diff --git a/protobuf/lib/src/protobuf/field_set.dart b/protobuf/lib/src/protobuf/field_set.dart index af86d641a..89930dee8 100644 --- a/protobuf/lib/src/protobuf/field_set.dart +++ b/protobuf/lib/src/protobuf/field_set.dart @@ -370,7 +370,7 @@ class _FieldSet { } /// The implementation of a generated getter for repeated fields. - List _$getList(int index) { + PbList _$getList(int index) { final value = _values[index]; if (value != null) return value; @@ -387,9 +387,9 @@ class _FieldSet { } /// The implementation of a generated getter for map fields. - Map _$getMap(GeneratedMessage parentMessage, int index) { + PbMap _$getMap(GeneratedMessage parentMessage, int index) { final value = _values[index]; - if (value != null) return value as Map; + if (value != null) return value; final fi = _nonExtensionInfoByIndex(index) as MapFieldInfo; assert(fi.isMapField); diff --git a/protobuf/lib/src/protobuf/generated_message.dart b/protobuf/lib/src/protobuf/generated_message.dart index cc4d3d64b..d34dac4ad 100644 --- a/protobuf/lib/src/protobuf/generated_message.dart +++ b/protobuf/lib/src/protobuf/generated_message.dart @@ -417,11 +417,12 @@ abstract class GeneratedMessage { /// For generated code only. /// @nodoc - List $_getList(int index) => _fieldSet._$getList(index); + PbList $_getList(int index) => _fieldSet._$getList(index); /// For generated code only. /// @nodoc - Map $_getMap(int index) => _fieldSet._$getMap(this, index); + PbMap $_getMap(int index) => + _fieldSet._$getMap(this, index); /// For generated code only. /// @nodoc diff --git a/protoc_plugin/CHANGELOG.md b/protoc_plugin/CHANGELOG.md index 566346ce9..0684291b0 100644 --- a/protoc_plugin/CHANGELOG.md +++ b/protoc_plugin/CHANGELOG.md @@ -1,8 +1,13 @@ ## 22.0.0-dev * Remove `PbEventMixin` mixin. ([#738]) +* Type of repeated fields is now `PbList` (instead of `List`), type of map + fields is now `PbMap` (instead of `Map`). ([#903]) + + This change requires protobuf-4.0.0. [#738]: https://github.com/google/protobuf.dart/issues/738 +[#903]: https://github.com/google/protobuf.dart/pull/903 ## 21.1.2 diff --git a/protoc_plugin/lib/src/base_type.dart b/protoc_plugin/lib/src/base_type.dart index 6cc7ae5b0..c49810812 100644 --- a/protoc_plugin/lib/src/base_type.dart +++ b/protoc_plugin/lib/src/base_type.dart @@ -54,7 +54,7 @@ class BaseType { : prefixed; String getRepeatedDartType(FileGenerator fileGen) => - '$coreImportPrefix.List<${getDartType(fileGen)}>'; + '$protobufImportPrefix.PbList<${getDartType(fileGen)}>'; String getRepeatedDartTypeIterable(FileGenerator fileGen) => '$coreImportPrefix.Iterable<${getDartType(fileGen)}>'; diff --git a/protoc_plugin/lib/src/protobuf_field.dart b/protoc_plugin/lib/src/protobuf_field.dart index 8797d0ea7..b4ca5d1d0 100644 --- a/protoc_plugin/lib/src/protobuf_field.dart +++ b/protoc_plugin/lib/src/protobuf_field.dart @@ -146,7 +146,7 @@ class ProtobufField { final d = baseType.generator as MessageGenerator; final keyType = d._fieldList[0].baseType.getDartType(parent.fileGen!); final valueType = d._fieldList[1].baseType.getDartType(parent.fileGen!); - return '$coreImportPrefix.Map<$keyType, $valueType>'; + return '$protobufImportPrefix.PbMap<$keyType, $valueType>'; } if (isRepeated) return baseType.getRepeatedDartType(parent.fileGen!); return baseType.getDartType(parent.fileGen!);