| /* |
| * 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. |
| */ |
| /** |
| * @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)]. |
| * |
| * If a class [C] in an opted-in library overrides a member, it is an error if |
| * its signature is not a subtype of the types of all overriden members from all |
| * super-interfaces (whether legacy or opted-in). For the purposes of override |
| * checking, members which are inherited from opted-in classes through legacy |
| * classes are still checked against each original declaration at its opted-in |
| * type. For example, the following override is considered an error. |
| * |
| * // opted_in.dart |
| * class A { |
| * int foo(int? x) {} |
| * } |
| * // opted_out.dart |
| * // @dart = 2.6 |
| * import 'opted_in.dart'; |
| * |
| * class B extends A {} |
| * // opted_in.dart |
| * class C extends B { |
| * // Override checking is done against the opted-in signature of A.foo |
| * int? foo(int x) {} |
| * } |
| * |
| * @description Check that if legacy class inherits a method with parameter |
| * from two opted in classes with contradictory nullability information and than |
| * this method is inherited again in the opted in code, compile error appears |
| * for non-nullable parameter. |
| * |
| * @Issue 40414 |
| * @author iarkh@unipro.ru |
| */ |
| // SharedOptions=--enable-experiment=non-nullable |
| // Requirements=nnbd-strong |
| |
| import "override_checking_A03_opted_out_lib.dart"; |
| |
| class A extends LEGACY_ARGS_2 { |
| void test_int (int? i) {} |
| void test_object (Object? o) {} |
| void test_function(Function? f) {} |
| } |
| |
| class B extends LEGACY_ARGS_2 { |
| void test_int (int i) {} |
| // ^^^^^^^^ |
| // [analyzer] unspecified |
| // [cfe] unspecified |
| |
| void test_object (Object o) {} |
| // ^^^^^^^^^^^ |
| // [analyzer] unspecified |
| // [cfe] unspecified |
| |
| void test_function(Function f) {} |
| // ^^^^^^^^^^^^^ |
| // [analyzer] unspecified |
| // [cfe] unspecified |
| } |
| |
| main() { |
| A(); |
| B(); |
| } |