-
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
#2087. Add tests for parameters covariant-by-declaration #2121
Conversation
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.
Looks good! We should have some extra cases, though: The modifier covariant
should have the same effect if it is specified in the member declaration where the covariant change of the type actually occurs, but the entire set of tests should work the same when covariant
is specified on a superinterface:
class A {
void m1(covariant num n) {}
}
class C extends A {
void m1(int n) {}
}
Similarly, it should also work the same when the modifier is added by some other superinterface; let's just do implements
:
class A {
void m1(num n) {}
}
abstract class B {
void m1(covariant num n);
}
class C extends A implements B {
void m1(int i) {}
}
Language/Functions/Formal_Parameters/Covariant_Parameters/no_instance_t01.dart
Show resolved
Hide resolved
Tests updated. Please take another look |
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.
Looks good! One little bit still missing:
I was worried when I saw that some tests have covariant
in more than one location in the superinterface graph. The strongest test occurs when it is in just one place (the extends
type, the implements
type, the on
type, or in the newly declared class itself), so we should cover the different kinds of locations with just one occurrence of covariant
.
A couple of tests have multiple occurrences (Language/Classes/Instance_Methods/covariant_A01_t05.dart and Language/Classes/Instance_Methods/covariant_A01_t06.dart). It's fine to have that test case, too, but we should make sure that we're covering each location separately.
I think there's no occurrence of covariant
in an on
type?
Updated. Excessive As for There will be one renaming PR after the merge to reorder these tests. It's much simpler to manage the tests if the similar tests are following each other |
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, LGTM!
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.
Oh, one thing needs to be reconsidered after all:
I'm worried that we won't get the static analysis if there are syntax errors. But no_instance_t01.dart
has a syntax error: Line 87 declares a setter as a local function, but that's a syntax error. The spec_parser complains about line 112-120 or so as well, but that disappears when the setter has been removed.
Also h2
needs to use parameter type int?
or have a default value such that we get an error for the correct reason (everything other than the word covariant
should be correct).
Ups, sorry. Fixed. |
2023-07-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2132. Fix roll failures, add issue numbers (dart-lang/co19#2134) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2130. Fix roll failures, add issues numbers (dart-lang/co19#2131) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2125. Add more external functions tests (dart-lang/co19#2128) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2087. Reorder covariance tests to make maintenance easier (dart-lang/co19#2129) 2023-07-12 sgrekhov22@gmail.com dart-lang/co19#2087. Add tests for parameters covariant-by-declaration (dart-lang/co19#2121) 2023-07-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2117. Update assertions, add tests for external members (dart-lang/co19#2126) 2023-07-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2123. Update Superclasses tests. (dart-lang/co19#2124) 2023-07-11 sgrekhov22@gmail.com dart-lang/co19#2117. Update accessible_instance_member_t* tests (dart-lang/co19#2122) 2023-07-10 sgrekhov22@gmail.com Fixes dart-lang/co19#2099. Add subtyping tests for function type with required named arguments (dart-lang/co19#2100) 2023-07-10 sgrekhov22@gmail.com dart-lang/co19#2112. Add missing tests for mixins. Part 2 (dart-lang/co19#2118) 2023-07-07 sgrekhov22@gmail.com dart-lang/co19#2119. Minor wording changes (dart-lang/co19#2120) Change-Id: I310f2e0a660ac55a242bb9b2ed9a2f1917555d0f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313562 Reviewed-by: Alexander Thomas <athom@google.com>
2023-07-14 sgrekhov22@gmail.com Fixes dart-lang/co19#2132. Fix roll failures, add issue numbers (dart-lang/co19#2134) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2130. Fix roll failures, add issues numbers (dart-lang/co19#2131) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2125. Add more external functions tests (dart-lang/co19#2128) 2023-07-13 sgrekhov22@gmail.com Fixes dart-lang/co19#2087. Reorder covariance tests to make maintenance easier (dart-lang/co19#2129) 2023-07-12 sgrekhov22@gmail.com dart-lang/co19#2087. Add tests for parameters covariant-by-declaration (dart-lang/co19#2121) 2023-07-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2117. Update assertions, add tests for external members (dart-lang/co19#2126) 2023-07-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2123. Update Superclasses tests. (dart-lang/co19#2124) 2023-07-11 sgrekhov22@gmail.com dart-lang/co19#2117. Update accessible_instance_member_t* tests (dart-lang/co19#2122) 2023-07-10 sgrekhov22@gmail.com Fixes dart-lang/co19#2099. Add subtyping tests for function type with required named arguments (dart-lang/co19#2100) 2023-07-10 sgrekhov22@gmail.com dart-lang/co19#2112. Add missing tests for mixins. Part 2 (dart-lang/co19#2118) 2023-07-07 sgrekhov22@gmail.com dart-lang/co19#2119. Minor wording changes (dart-lang/co19#2120) Change-Id: I310f2e0a660ac55a242bb9b2ed9a2f1917555d0f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313562 Reviewed-by: Alexander Thomas <athom@google.com>
No description provided.