@@ -944,13 +944,13 @@ void Object::Init(Isolate* isolate) {
944944 cls.set_is_type_finalized();
945945
946946 cls = dynamic_class_;
947- *dynamic_type_ = Type::NewNonParameterizedType(cls, Nullability:: kNullable);
947+ *dynamic_type_ = Type::NewNonParameterizedType(cls, kNullable);
948948
949949 cls = void_class_;
950- *void_type_ = Type::NewNonParameterizedType(cls, Nullability:: kNullable);
950+ *void_type_ = Type::NewNonParameterizedType(cls, kNullable);
951951
952952 cls = never_class_;
953- *never_type_ = Type::NewNonParameterizedType(cls, Nullability:: kNonNullable);
953+ *never_type_ = Type::NewNonParameterizedType(cls, kNonNullable);
954954
955955 // Since TypeArguments objects are passed as function arguments, make them
956956 // behave as Dart instances, although they are just VM objects.
@@ -1934,7 +1934,7 @@ RawError* Object::Init(Isolate* isolate,
19341934 // name is a built-in identifier (this is wrong). The corresponding types
19351935 // are stored in the object store.
19361936 cls = object_store->null_class();
1937- type = Type::NewNonParameterizedType(cls, Nullability:: kNullable);
1937+ type = Type::NewNonParameterizedType(cls, kNullable);
19381938 cls.set_declaration_type(type);
19391939 object_store->set_null_type(type);
19401940 ASSERT(type.IsNullable());
@@ -4345,7 +4345,7 @@ RawType* Class::DeclarationType(Nullability nullability) const {
43454345 ASSERT(is_declaration_loaded());
43464346 if (IsNullClass()) {
43474347 // Ignore requested nullability (e.g. by mirrors).
4348- nullability = Nullability:: kNullable;
4348+ nullability = kNullable;
43494349 }
43504350 Type& type = Type::Handle(declaration_type());
43514351 if (!type.IsNull()) {
@@ -16664,8 +16664,8 @@ RawAbstractType* Instance::GetType(Heap::Space space) const {
1666416664 }
1666516665 // TODO(regis): The runtime type of a non-null instance should be
1666616666 // non-nullable instead of legacy. Revisit.
16667- type = Type::New(cls, type_arguments, TokenPosition::kNoSource,
16668- Nullability::kLegacy, space);
16667+ type = Type::New(cls, type_arguments, TokenPosition::kNoSource, kLegacy,
16668+ space);
1666916669 type.SetIsFinalized();
1667016670 type ^= type.Canonicalize();
1667116671 }
@@ -17019,7 +17019,7 @@ TokenPosition AbstractType::token_pos() const {
1701917019Nullability AbstractType::nullability() const {
1702017020 // AbstractType is an abstract class.
1702117021 UNREACHABLE();
17022- return Nullability:: kNullable;
17022+ return kNullable;
1702317023}
1702417024
1702517025bool AbstractType::IsInstantiated(Genericity genericity,
@@ -17201,21 +17201,8 @@ RawString* AbstractType::PrintURIs(URIs* uris) {
1720117201 return Symbols::FromConcatAll(thread, pieces);
1720217202}
1720317203
17204- static const String& NullabilitySuffix(Nullability value) {
17205- // Keep in sync with Nullability enum in runtime/vm/object.h.
17206- switch (value) {
17207- case Nullability::kUndetermined:
17208- return Symbols::Percent();
17209- case Nullability::kNullable:
17210- return Symbols::QuestionMark();
17211- case Nullability::kNonNullable:
17212- return Symbols::Empty();
17213- case Nullability::kLegacy:
17214- return Symbols::Star();
17215- default:
17216- UNREACHABLE();
17217- }
17218- }
17204+ // Keep in sync with Nullability enum in runtime/vm/object.h.
17205+ static const char* nullability_suffix[4] = {"%", "?", "", "*"};
1721917206
1722017207RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1722117208 ASSERT(name_visibility != kScrubbedName);
@@ -17225,7 +17212,7 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1722517212 if (FLAG_show_nullability) {
1722617213 return Symbols::FromConcat(
1722717214 thread, String::Handle(zone, TypeParameter::Cast(*this).name()),
17228- NullabilitySuffix( nullability()));
17215+ String::Handle(zone, String::New(nullability_suffix[ nullability()] )));
1722917216 }
1723017217 return TypeParameter::Cast(*this).name();
1723117218 }
@@ -17243,7 +17230,8 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1724317230 return Symbols::FromConcat(
1724417231 thread,
1724517232 String::Handle(zone, signature_function.UserVisibleSignature()),
17246- NullabilitySuffix(nullability()));
17233+ String::Handle(zone,
17234+ String::New(nullability_suffix[nullability()])));
1724717235 }
1724817236 return signature_function.UserVisibleSignature();
1724917237 }
@@ -17253,9 +17241,10 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1725317241 if (!IsFinalized() || IsBeingFinalized()) {
1725417242 // TODO(regis): Check if this is dead code.
1725517243 if (FLAG_show_nullability) {
17256- return Symbols::FromConcat(thread,
17257- String::Handle(zone, class_name.raw()),
17258- NullabilitySuffix(nullability()));
17244+ return Symbols::FromConcat(
17245+ thread, String::Handle(zone, class_name.raw()),
17246+ String::Handle(zone,
17247+ String::New(nullability_suffix[nullability()])));
1725917248 }
1726017249 return class_name.raw();
1726117250 }
@@ -17298,7 +17287,8 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1729817287 pieces.Add(args_name);
1729917288 }
1730017289 if (FLAG_show_nullability) {
17301- pieces.Add(NullabilitySuffix(nullability()));
17290+ pieces.Add(
17291+ String::Handle(zone, String::New(nullability_suffix[nullability()])));
1730217292 }
1730317293 // The name is only used for type checking and debugging purposes.
1730417294 // Unless profiling data shows otherwise, it is not worth caching the name in
@@ -17337,7 +17327,7 @@ bool AbstractType::IsTopType(NNBDMode mode) const {
1733717327 return false;
1733817328 }
1733917329 if (cid == kDynamicCid || cid == kVoidCid ||
17340- (cid == kInstanceCid && (mode != NNBDMode:: kStrong || IsNullable()))) {
17330+ (cid == kInstanceCid && (mode != kStrong || IsNullable()))) {
1734117331 return true;
1734217332 }
1734317333 // FutureOr<T> where T is a top type behaves as a top type.
@@ -18473,7 +18463,7 @@ void TypeParameter::SetGenericCovariantImpl(bool value) const {
1847318463}
1847418464
1847518465void TypeParameter::set_nullability(Nullability value) const {
18476- StoreNonPointer(&raw_ptr()->nullability_, static_cast<int8_t>( value) );
18466+ StoreNonPointer(&raw_ptr()->nullability_, value);
1847718467}
1847818468
1847918469RawTypeParameter* TypeParameter::ToNullability(Nullability value,
@@ -18672,7 +18662,7 @@ RawTypeParameter* TypeParameter::New(const Class& parameterized_class,
1867218662 result.set_name(name);
1867318663 result.set_bound(bound);
1867418664 result.set_flags(0);
18675- result.set_nullability(Nullability:: kLegacy);
18665+ result.set_nullability(kLegacy);
1867618666 result.SetGenericCovariantImpl(is_generic_covariant_impl);
1867718667 result.SetHash(0);
1867818668 result.set_token_pos(token_pos);
0 commit comments