-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2080. Add correct member overrides tests. Part 2. Setters #2093
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t19.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,39 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is a compile-time error if `m` and `m′` are both | ||
/// setters and function type `m` is not a subtype of `m′`. Test `implements` | ||
/// clause | ||
/// @author [email protected] | ||
|
||
interface class I { | ||
void set m(num n) {} | ||
} | ||
|
||
class C implements I { | ||
void set m(int i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M implements I { | ||
void set m(int i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
43 changes: 43 additions & 0 deletions
43
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t20.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,43 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is a compile-time error if `m` and `m′` are both | ||
/// setters and function type `m` is not a subtype of `m′`. Test `implements` | ||
/// clause | ||
/// @author [email protected] | ||
|
||
interface class I1 { | ||
void set m(int i) {} | ||
} | ||
|
||
interface class I2 { | ||
void set m(Object i) {} | ||
} | ||
|
||
class C implements I1, I2 { | ||
void set m(num i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M implements I1, I2 { | ||
void set m(num i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
35 changes: 35 additions & 0 deletions
35
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t21.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,35 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is not an error if `m` and `m′` are both setters | ||
/// and function type `m` is a subtype of `m′. Test `implements` clause | ||
/// @author [email protected] | ||
|
||
interface class I { | ||
void set m1(num v1) {} | ||
void set m2(covariant int v1) {} | ||
} | ||
|
||
class C implements I { | ||
void set m1(covariant int i) {} | ||
void set m2(num i) {} | ||
} | ||
|
||
mixin M implements I { | ||
void set m1(covariant int i) {} | ||
void set m2(num i) {} | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
36 changes: 36 additions & 0 deletions
36
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t22.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,36 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is not an error if `m` and `m′` are both setters | ||
/// and function type `m` is a subtype of `m′. Test `implements` clause | ||
/// @author [email protected] | ||
|
||
interface class I1 { | ||
void set m(num v1) {} | ||
} | ||
|
||
interface class I2 { | ||
void set m(covariant int v1) {} | ||
} | ||
|
||
class C implements I1, I2 { | ||
void set m(covariant int i) {} | ||
} | ||
|
||
mixin M implements I1, I2 { | ||
void set m(num i) {} | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
50 changes: 50 additions & 0 deletions
50
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t23.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,50 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is a compile-time error if `m` and `m′` are both | ||
/// setters and function type `m` is not a subtype of `m′. Test `implements` | ||
/// clause | ||
/// @author [email protected] | ||
|
||
interface class I { | ||
void set m1(num v1) {} | ||
void set m2(covariant int v1) {} | ||
} | ||
|
||
class C implements I { | ||
void set m1(covariant String i) {} | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
void set m2(String i) {} | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M implements I { | ||
void set m1(covariant String i) {} | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
void set m2(String i) {} | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
39 changes: 39 additions & 0 deletions
39
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t24.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,39 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is a compile-time error if `m` and `m′` are both | ||
/// setters and function type `m` is not a subtype of `m′`. Test `extends` and | ||
/// `on` clauses | ||
/// @author [email protected] | ||
|
||
interface class I { | ||
void set m(num n) {} | ||
} | ||
|
||
class C extends I { | ||
void set m(int i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M on I { | ||
void set m(int i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
43 changes: 43 additions & 0 deletions
43
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t25.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,43 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is a compile-time error if `m` and `m′` are both | ||
/// setters and function type `m` is not a subtype of `m′`. Test `extends` and | ||
/// `on` clauses | ||
/// @author [email protected] | ||
|
||
interface class I1 { | ||
void set m(int i) {} | ||
} | ||
|
||
interface class I2 { | ||
void set m(Object i) {} | ||
} | ||
|
||
class C extends I1 implements I2 { | ||
void set m(num i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M on I2 implements I1 { | ||
void set m(num i) {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
35 changes: 35 additions & 0 deletions
35
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t26.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,35 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is not an error if `m` and `m′` are both setters | ||
/// and function type `m` is a subtype of `m′. Test `extends` and `on` clauses | ||
/// @author [email protected] | ||
|
||
interface class I { | ||
void set m1(num v1) {} | ||
void set m2(covariant int v1) {} | ||
} | ||
|
||
class C extends I { | ||
void set m1(covariant int i) {} | ||
void set m2(num i) {} | ||
} | ||
|
||
mixin M on I { | ||
void set m1(covariant int i) {} | ||
void set m2(num i) {} | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
36 changes: 36 additions & 0 deletions
36
Language/Interfaces/Correct_Member_Overrides/correct_member_overrides_A03_t27.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,36 @@ | ||
// Copyright (c) 2023, 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′. | ||
/// | ||
/// @description Checks that it is not an error if `m` and `m′` are both setters | ||
/// and function type `m` is a subtype of `m′. Test `extends` and `on` clauses | ||
/// @author [email protected] | ||
|
||
interface class I1 { | ||
void set m(num v1) {} | ||
} | ||
|
||
interface class I2 { | ||
void set m(covariant int v1) {} | ||
} | ||
|
||
class C extends I1 implements I2 { | ||
void set m(covariant int i) {} | ||
} | ||
|
||
mixin M on I2 implements I1 { | ||
void set m(num i) {} | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(M); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect to see
Object?
instead ofObject
in this line. Could you point me to the part of the spec this quote is taken from?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a comment, it can be resolved in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Spec link https://github.com/dart-lang/language/blob/6d50316bac4e4f1d17367bb5440fe5d2da298ad3/specification/dartLangSpec.tex#L5373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! That looks interesting :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With null safety, that should be
Object?
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it should be
Object?
too, but the spec does sayObject
. Should we update the spec as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec updates for null safety are in review (...since september 2021...). It is in the PR dart-lang/language#2605: It was missing, but I just corrected that. So it will be landed along with all the other null safety changes.