@@ -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, kNullable);
947+ *dynamic_type_ = Type::NewNonParameterizedType(cls, Nullability:: kNullable);
948948
949949 cls = void_class_;
950- *void_type_ = Type::NewNonParameterizedType(cls, kNullable);
950+ *void_type_ = Type::NewNonParameterizedType(cls, Nullability:: kNullable);
951951
952952 cls = never_class_;
953- *never_type_ = Type::NewNonParameterizedType(cls, kNonNullable);
953+ *never_type_ = Type::NewNonParameterizedType(cls, Nullability:: 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, kNullable);
1937+ type = Type::NewNonParameterizedType(cls, Nullability:: 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 = kNullable;
4348+ nullability = 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, kLegacy,
16668- space);
16667+ type = Type::New(cls, type_arguments, TokenPosition::kNoSource,
16668+ Nullability::kLegacy, 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 kNullable;
17022+ return Nullability:: kNullable;
1702317023}
1702417024
1702517025bool AbstractType::IsInstantiated(Genericity genericity,
@@ -17201,8 +17201,21 @@ RawString* AbstractType::PrintURIs(URIs* uris) {
1720117201 return Symbols::FromConcatAll(thread, pieces);
1720217202}
1720317203
17204- // Keep in sync with Nullability enum in runtime/vm/object.h.
17205- static const char* nullability_suffix[4] = {"%", "?", "", "*"};
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+ }
1720617219
1720717220RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1720817221 ASSERT(name_visibility != kScrubbedName);
@@ -17212,7 +17225,7 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1721217225 if (FLAG_show_nullability) {
1721317226 return Symbols::FromConcat(
1721417227 thread, String::Handle(zone, TypeParameter::Cast(*this).name()),
17215- String::Handle(zone, String::New(nullability_suffix[ nullability()] )));
17228+ NullabilitySuffix( nullability()));
1721617229 }
1721717230 return TypeParameter::Cast(*this).name();
1721817231 }
@@ -17230,8 +17243,7 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1723017243 return Symbols::FromConcat(
1723117244 thread,
1723217245 String::Handle(zone, signature_function.UserVisibleSignature()),
17233- String::Handle(zone,
17234- String::New(nullability_suffix[nullability()])));
17246+ NullabilitySuffix(nullability()));
1723517247 }
1723617248 return signature_function.UserVisibleSignature();
1723717249 }
@@ -17241,10 +17253,9 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1724117253 if (!IsFinalized() || IsBeingFinalized()) {
1724217254 // TODO(regis): Check if this is dead code.
1724317255 if (FLAG_show_nullability) {
17244- return Symbols::FromConcat(
17245- thread, String::Handle(zone, class_name.raw()),
17246- String::Handle(zone,
17247- String::New(nullability_suffix[nullability()])));
17256+ return Symbols::FromConcat(thread,
17257+ String::Handle(zone, class_name.raw()),
17258+ NullabilitySuffix(nullability()));
1724817259 }
1724917260 return class_name.raw();
1725017261 }
@@ -17287,8 +17298,7 @@ RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
1728717298 pieces.Add(args_name);
1728817299 }
1728917300 if (FLAG_show_nullability) {
17290- pieces.Add(
17291- String::Handle(zone, String::New(nullability_suffix[nullability()])));
17301+ pieces.Add(NullabilitySuffix(nullability()));
1729217302 }
1729317303 // The name is only used for type checking and debugging purposes.
1729417304 // Unless profiling data shows otherwise, it is not worth caching the name in
@@ -17327,7 +17337,7 @@ bool AbstractType::IsTopType(NNBDMode mode) const {
1732717337 return false;
1732817338 }
1732917339 if (cid == kDynamicCid || cid == kVoidCid ||
17330- (cid == kInstanceCid && (mode != kStrong || IsNullable()))) {
17340+ (cid == kInstanceCid && (mode != NNBDMode:: kStrong || IsNullable()))) {
1733117341 return true;
1733217342 }
1733317343 // FutureOr<T> where T is a top type behaves as a top type.
@@ -18463,7 +18473,7 @@ void TypeParameter::SetGenericCovariantImpl(bool value) const {
1846318473}
1846418474
1846518475void TypeParameter::set_nullability(Nullability value) const {
18466- StoreNonPointer(&raw_ptr()->nullability_, value);
18476+ StoreNonPointer(&raw_ptr()->nullability_, static_cast<int8_t>( value) );
1846718477}
1846818478
1846918479RawTypeParameter* TypeParameter::ToNullability(Nullability value,
@@ -18662,7 +18672,7 @@ RawTypeParameter* TypeParameter::New(const Class& parameterized_class,
1866218672 result.set_name(name);
1866318673 result.set_bound(bound);
1866418674 result.set_flags(0);
18665- result.set_nullability(kLegacy);
18675+ result.set_nullability(Nullability:: kLegacy);
1866618676 result.SetGenericCovariantImpl(is_generic_covariant_impl);
1866718677 result.SetHash(0);
1866818678 result.set_token_pos(token_pos);
0 commit comments