Skip to content

Commit 82aa7e7

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Revert "[VM/nnbd] Force the DeclarationType of a class to have legacy nullability."
This reverts commit 3771ddd. Reason for revert: see https://buganizer.corp.google.com/issues/144304690 (This CL is dependent on https://dart-review.googlesource.com/c/sdk/+/124480 which caused the regression). Original change's description: > [VM/nnbd] Force the DeclarationType of a class to have legacy nullability. > > This is a workaround to avoid caching a non-legacy type (possibly provided > by the CFE) as the canonical type of a non-generic class and later returned as > the runtime type of an instance of this class. > > Hopefully fixes https://buganizer.corp.google.com/issues/144304690 > > Change-Id: Iaea364b9b743b05bde600f0aa784d5a8105728d7 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124920 > Reviewed-by: Alexander Markov <alexmarkov@google.com> > Commit-Queue: Régis Crelier <regis@google.com> TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com,regis@google.com Change-Id: If8b2671f3cf4b0d080ba9f0472738326fec701d3 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125100 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
1 parent a7472ba commit 82aa7e7

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

runtime/vm/object.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,16 +4351,11 @@ RawType* Class::DeclarationType(Nullability nullability) const {
43514351
if (!type.IsNull()) {
43524352
return type.ToNullability(nullability, Heap::kOld);
43534353
}
4354-
// TODO(regis): We should pass nullabiity to Type::New to avoid having to
4355-
// clone the type to the desired nullability. This however causes issues with
4356-
// the runtimeType intrinsic grabbing DeclarationType without checking its
4357-
// nullability. Indeed, when the CFE provides a non-nullable version of the
4358-
// type first, this non-nullable version gets cached as the declaration type.
43594354
type = Type::New(*this, TypeArguments::Handle(type_parameters()), token_pos(),
4360-
Nullability::kLegacy);
4355+
nullability);
43614356
type ^= ClassFinalizer::FinalizeType(*this, type);
43624357
set_declaration_type(type);
4363-
return type.ToNullability(nullability, Heap::kOld);
4358+
return type.raw();
43644359
}
43654360

43664361
void Class::set_allocation_stub(const Code& value) const {

0 commit comments

Comments
 (0)