blob: d6a3f24518655335fd619353d5ebe86c7f371b76 [file] [log] [blame]
/*
* 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 getter from two opted in
* classes with contradictory nullability information and than this getter is
* inherited again in the opted in code, compile error appears.
*
* @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_GETTER_2 {
int? get getInt => null;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Object? get getObject => null;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Function? get getFunction => null;
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
void testme() {}
class B extends LEGACY_GETTER_2 {
int get getInt => 1;
Object get getObject => 1;
Function get getFunction => testme;
}
main() {
A();
B();
}