@@ -44,7 +44,8 @@ abstract class Serializers {
4444 /// Create one using [SerializersBuilder] .
4545 ///
4646 /// TODO(davidmorgan): document the wire format.
47- Object serialize (Object object, {FullType specifiedType: const FullType ()});
47+ Object serialize (Object object,
48+ {FullType specifiedType: FullType .unspecified});
4849
4950 /// Deserializes [serialized] .
5051 ///
@@ -53,7 +54,7 @@ abstract class Serializers {
5354 /// If [serialized] was produced by calling [serialize] with [specifiedType] ,
5455 /// the exact same [specifiedType] must be provided to deserialize.
5556 Object deserialize (Object serialized,
56- {FullType specifiedType: const FullType () });
57+ {FullType specifiedType: FullType .unspecified });
5758
5859 /// Creates a new builder for the type represented by [fullType] .
5960 ///
@@ -83,23 +84,29 @@ abstract class SerializersBuilder {
8384}
8485
8586/// A [Type] with, optionally, [FullType] generic type parameters.
87+ ///
88+ /// May also be [unspecified] , indicating that no type information is
89+ /// available.
8690class FullType {
91+ // An unspecified type.
92+ static const unspecified = const FullType (null );
93+
8794 /// The root of the type.
8895 final Type root;
8996
9097 /// Type parameters of the type.
9198 final List <FullType > parameters;
9299
93- const FullType ([ this .root = Object , this .parameters = const []]);
100+ const FullType (this .root, [ this .parameters = const []]);
94101
95- bool get isObject => root == Object ;
102+ bool get isUnspecified => identical ( root, null ) ;
96103
97104 @override
98- String toString () {
99- return parameters.isEmpty
100- ? root. toString ()
101- : '${ root .toString ()}<${ parameters . join ( ", " )}>' ;
102- }
105+ String toString () => isUnspecified
106+ ? 'unspecified'
107+ : parameters.isEmpty
108+ ? root.toString ()
109+ : '${ root . toString ()}<${ parameters . join ( ", " )}>' ;
103110}
104111
105112/// Serializes a single type.
@@ -131,12 +138,12 @@ abstract class Serializer<T> {
131138 ///
132139 /// TODO(davidmorgan): document the wire format.
133140 Object serialize (Serializers serializers, T object,
134- {FullType specifiedType: const FullType () });
141+ {FullType specifiedType: FullType .unspecified });
135142
136143 /// Deserializes [serialized] .
137144 ///
138145 /// Use [serializers] as needed for nested deserialization. Information about
139146 /// the type being deserialized is provided in [specifiedType] .
140147 T deserialize (Serializers serializers, Object serialized,
141- {FullType specifiedType: const FullType () });
148+ {FullType specifiedType: FullType .unspecified });
142149}
0 commit comments