Skip to content
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

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

sgrekhov
Copy link
Contributor

No description provided.

Copy link
Member

@eernstg eernstg left a 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) {}
}

@sgrekhov
Copy link
Contributor Author

Tests updated. Please take another look

@sgrekhov sgrekhov requested a review from eernstg July 11, 2023 09:01
Copy link
Member

@eernstg eernstg left a 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?

Language/Classes/Instance_Methods/covariant_A01_t05.dart Outdated Show resolved Hide resolved
@sgrekhov
Copy link
Contributor Author

Updated. Excessive covariant were just a copy/paste effect. The intention was to left only one covariant in the superinterface graph. Thank you for noticing. Removed.

As for mixin M on I forgot about it. Added appropriate tests.

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

@sgrekhov sgrekhov requested a review from eernstg July 11, 2023 14:51
Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

Copy link
Member

@eernstg eernstg left a 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).

@sgrekhov
Copy link
Contributor Author

Ups, sorry. Fixed.

@sgrekhov sgrekhov requested a review from eernstg July 11, 2023 20:06
@eernstg eernstg merged commit 28e9069 into dart-lang:master Jul 12, 2023
2 checks passed
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jul 14, 2023
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>
osa1 pushed a commit to osa1/sdk that referenced this pull request Jul 17, 2023
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>
@sgrekhov sgrekhov deleted the co19-2087-2 branch July 18, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants