forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes dart-lang#3063. Add additional "correct member overrides" test
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A03_t29.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
/// @issue 60011 | ||
class A<T extends num> { | ||
X foo<X extends T>(X x) => x; | ||
} | ||
|
||
class C<T extends num> extends A<num> { | ||
int v; | ||
C(this.v); | ||
X foo<X extends T>(X x) => x + v as X; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
void main() { | ||
C<int>(1); | ||
} |