From c10a9f51e078937c59a78c90e5b0780c1178e549 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 3 Feb 2025 11:57:45 +0200 Subject: [PATCH] Fixes #3063. Add additional "correct member overrides" test --- .../correct_member_overrides_A03_t29.dart | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A03_t29.dart diff --git a/Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A03_t29.dart b/Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A03_t29.dart new file mode 100644 index 0000000000..2c59c7b2c9 --- /dev/null +++ b/Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A03_t29.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2025, 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 Let `m` and `m′` be member signatures with the same name `id`. +/// Then `m` is a correct override of `m′` iff the following criteria are all +/// satisfied: +/// ... +/// • If `m` and `m′` are both methods or both setters: Let F be the function +/// type of `m` except that the parameter type is the built-in class `Object` +/// for each parameter of `m` which is covariant-by-declaration. Let `F′` be +/// the function type of `m′`. `F` must then be a subtype of `F′`. +/// +/// Note that a parameter which is covariant-by-declaration must have a type +/// which satisfies one more requirement, relative to the corresponding +/// parameters in all superinterfaces, both direct and indirect +/// +/// @description Checks that it is a compile-time error if `m` and `m′` are both +/// generic methods and a function type of `m` is not a subtype of `m′. +/// @author sgrekhov22@gmail.com +/// @issue 60011 + +class A { + X foo(X x) => x; +} + +class C extends A { + int v; + C(this.v); + X foo(X x) => x + v as X; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +void main() { + C(1); +}