blob: a10876c63fb5d0dbaf005876d24d223044709f1d [file] [log] [blame]
// Copyright (c) 2021, 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.
/// @assertion If a class [C] in an opted-in library implements the same generic
/// class [I] more than once as [I0], .., [In], and at least one of the [Ii] is
/// not syntactically equal to the others, then it is an error if
/// [NNBD_TOP_MERGE(S0, ..., Sn)] is not defined where [Si] is [NORM(Ii)].
/// Otherwise, for the purposes of runtime subtyping checks, [C] is considered to
/// implement the canonical interface given by [NNBD_TOP_MERGE(S0, ..., Sn)].
///
/// @description Check that that the result of NNBD_TOP_MERGE(Object, Object)] is
/// [Object] in weak mode.
///
/// Dynamic type checks with unsound null checking erases `?` from types and add
/// `*` (recursively, so `List<int?>?` becomes `List<int*>*`). In particular
/// `LEGACY_SUBTYPE(Object Function(Object), Object? Function(Object?))` is true.
///
/// @author iarkh@unipro.ru
// Requirements=nnbd-weak
import "../../../../Utils/expect.dart";
class B extends CheckTopMerge<Object> {}
class C extends CheckTopMerge<Object> {}
class D extends B implements C {}
void main() {
Expect.isTrue(D().f is Object Function(Object));
Expect.isTrue(D().f is Object? Function(Object?));
Expect.runtimeIsType<Object Function(Object)>(D().f);
Expect.runtimeIsType<Object? Function(Object?)>(D().f);
}