[VM/kernel] Remove obsolete workaround when reading dynamic bound from kernel.

If the bound is not specified, CFE will use Object* in an opted-out library or Object? in an opted-in library, and not dynamic as before.
This workaround is therefore not needed anymore, and actually harmful as shown in the regression tests.

Closes https://github.com/dart-lang/sdk/issues/44136
Add regression tests.

Change-Id: I11a96cbebcb592f66f3965e38cb2411200df332b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171380
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
This commit is contained in:
Regis Crelier 2020-11-10 21:30:26 +00:00 committed by commit-bot@chromium.org
parent d7b3812f51
commit 9711b9a331
3 changed files with 26 additions and 13 deletions

View file

@ -3338,20 +3338,9 @@ void TypeTranslator::LoadAndSetupTypeParameters(
TypeParameterHelper helper(helper_);
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kBound);
// TODO(github.com/dart-lang/kernel/issues/42): This should be handled
// by the frontend.
parameter ^= type_parameters.TypeAt(i);
const Tag tag = helper_->PeekTag(); // peek ith bound type.
if (tag == kDynamicType) {
helper_->SkipDartType(); // read ith bound.
parameter.set_bound(
Type::Handle(Z, nnbd_mode == NNBDMode::kOptedInLib
? I->object_store()->nullable_object_type()
: I->object_store()->legacy_object_type()));
} else {
AbstractType& bound = BuildTypeWithoutFinalization(); // read ith bound.
parameter.set_bound(bound);
}
AbstractType& bound = BuildTypeWithoutFinalization(); // read ith bound.
parameter.set_bound(bound);
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kDefaultType);
const AbstractType* default_arg = &Object::dynamic_type();
if (helper_->ReadTag() == kSomething) {

View file

@ -0,0 +1,12 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
typedef Foo = void Function<X extends dynamic>();
typedef Bar = void Function<X extends Object?>();
void main() {
Expect.notEquals(Foo, Bar);
}

View file

@ -0,0 +1,12 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
typedef Foo = void Function<X extends dynamic>();
typedef Bar = void Function<X extends Object>();
void main() {
Expect.notEquals(Foo, Bar);
}