@@ -3921,8 +3921,7 @@ RawObject* Class::InvokeSetter(const String& setter_name,
39213921 }
39223922
39233923 AbstractType& parameter_type = AbstractType::Handle(zone);
3924- AbstractType& argument_type =
3925- AbstractType::Handle(zone, value.GetType(Heap::kOld));
3924+ NNBDMode mode = nnbd_mode();
39263925
39273926 if (field.IsNull()) {
39283927 const Function& setter =
@@ -3940,14 +3939,9 @@ RawObject* Class::InvokeSetter(const String& setter_name,
39403939 InvocationMirror::kSetter);
39413940 }
39423941 parameter_type = setter.ParameterTypeAt(0);
3943- if (nnbd_mode() != NNBDMode::kLegacyLib) {
3944- // TODO(regis): Make type check nullability aware.
3945- UNIMPLEMENTED();
3946- }
3947- if (!argument_type.IsNullType() && !parameter_type.IsDynamicType() &&
3948- !value.IsInstanceOf(nnbd_mode(), parameter_type,
3949- Object::null_type_arguments(),
3950- Object::null_type_arguments())) {
3942+ if (!value.RuntimeTypeIsSubtypeOf(mode, parameter_type,
3943+ Object::null_type_arguments(),
3944+ Object::null_type_arguments())) {
39513945 const String& argument_name =
39523946 String::Handle(zone, setter.ParameterNameAt(0));
39533947 return ThrowTypeError(setter.token_pos(), value, parameter_type,
@@ -3968,14 +3962,9 @@ RawObject* Class::InvokeSetter(const String& setter_name,
39683962 }
39693963
39703964 parameter_type = field.type();
3971- if (nnbd_mode() != NNBDMode::kLegacyLib) {
3972- // TODO(regis): Make type check nullability aware.
3973- UNIMPLEMENTED();
3974- }
3975- if (!argument_type.IsNullType() && !parameter_type.IsDynamicType() &&
3976- !value.IsInstanceOf(nnbd_mode(), parameter_type,
3977- Object::null_type_arguments(),
3978- Object::null_type_arguments())) {
3965+ if (!value.RuntimeTypeIsSubtypeOf(mode, parameter_type,
3966+ Object::null_type_arguments(),
3967+ Object::null_type_arguments())) {
39793968 const String& argument_name = String::Handle(zone, field.name());
39803969 return ThrowTypeError(field.token_pos(), value, parameter_type,
39813970 argument_name);
@@ -17438,11 +17427,7 @@ bool Instance::IsInstanceOf(
1743817427 const AbstractType& other,
1743917428 const TypeArguments& other_instantiator_type_arguments,
1744017429 const TypeArguments& other_function_type_arguments) const {
17441- ASSERT(other.IsFinalized());
1744217430 ASSERT(!other.IsDynamicType());
17443- ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
17444- // Note that Object::sentinel() has Null class, but !IsNull().
17445- ASSERT(raw() != Object::sentinel().raw());
1744617431 if (IsNull()) {
1744717432 return Instance::NullIsInstanceOf(mode, other,
1744817433 other_instantiator_type_arguments,
@@ -17459,11 +17444,7 @@ bool Instance::IsAssignableTo(
1745917444 const AbstractType& other,
1746017445 const TypeArguments& other_instantiator_type_arguments,
1746117446 const TypeArguments& other_function_type_arguments) const {
17462- ASSERT(other.IsFinalized());
1746317447 ASSERT(!other.IsDynamicType());
17464- ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
17465- // Note that Object::sentinel() has Null class, but !IsNull().
17466- ASSERT(raw() != Object::sentinel().raw());
1746717448 // In weak mode type casts, whether in legacy or opted-in libraries, the null
1746817449 // instance is detected and handled in inlined code and therefore cannot be
1746917450 // encountered here as a Dart null receiver.
@@ -17484,6 +17465,8 @@ bool Instance::NullIsInstanceOf(
1748417465 const AbstractType& other,
1748517466 const TypeArguments& other_instantiator_type_arguments,
1748617467 const TypeArguments& other_function_type_arguments) {
17468+ ASSERT(other.IsFinalized());
17469+ ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
1748717470 // TODO(regis): Verify that the nullability of an instantiated FutureOr
1748817471 // always matches the nullability of its type argument. For now, be safe.
1748917472 AbstractType& type = AbstractType::Handle(other.UnwrapFutureOr());
@@ -17516,8 +17499,9 @@ bool Instance::RuntimeTypeIsSubtypeOf(
1751617499 const TypeArguments& other_instantiator_type_arguments,
1751717500 const TypeArguments& other_function_type_arguments) const {
1751817501 ASSERT(other.IsFinalized());
17519- ASSERT(!other.IsDynamicType());
1752017502 ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
17503+ // Note that Object::sentinel() has Null class, but !IsNull().
17504+ ASSERT(raw() != Object::sentinel().raw());
1752117505 // Instance may not have runtimeType dynamic, void, or Never.
1752217506 if (other.IsTopType()) {
1752317507 return true;
0 commit comments