Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: lib/src/protobuf/field_info.dart

Issue 1844293003: Add generic types for strong mode (Closed) Base URL: git@github.com:dart-lang/dart-protobuf.git@master
Patch Set: oops, change all callers to use fi._createRepeatedField Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/protobuf/field_info.dart
diff --git a/lib/src/protobuf/field_info.dart b/lib/src/protobuf/field_info.dart
index d9235756a452b23b7ff3884dfdaa43a5c4a97ff7..0a7886963ff174e95462c06b98a620cd9d093963 100644
--- a/lib/src/protobuf/field_info.dart
+++ b/lib/src/protobuf/field_info.dart
@@ -7,7 +7,7 @@ part of protobuf;
/**
* An object representing a protobuf message field.
*/
-class FieldInfo {
+class FieldInfo<T> {
final String name;
final int tagNumber;
final int index; // index of the field's value. Null for extensions.
@@ -46,7 +46,7 @@ class FieldInfo {
[this.valueOf])
: this.type = type,
this.check = check,
- this.makeDefault = (() => new PbList(check: check)) {
+ this.makeDefault = (() => new PbList<T>(check: check)) {
skybrian 2016/04/01 18:01:40 This is a bit inconsistent. For a non-repeated fi
assert(name != null);
assert(tagNumber != null);
assert(_isRepeated(type));
@@ -121,5 +121,14 @@ class FieldInfo {
}
}
+ /// Creates a repeated field to be attached to the given message.
+ ///
+ /// Delegates actual list creation to the message, so that it can
+ /// be overridden by a mixin.
+ List<T> _createRepeatedField(GeneratedMessage m) {
+ assert(isRepeated);
+ return m.createRepeatedField/*<T>*/(tagNumber, this);
+ }
+
String toString() => name;
}

Powered by Google App Engine
This is Rietveld 408576698