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

+ implicit_reopen #4101

Merged
merged 33 commits into from
Mar 22, 2023
Merged

+ implicit_reopen #4101

merged 33 commits into from
Mar 22, 2023

Conversation

pq
Copy link
Member

@pq pq commented Mar 1, 2023

UPDATE: ready to land! 🦅

Fixes: #3920.


This is a WIP but far enough along that I could benefit from some feedback.

Specifically:

  1. @kallentu, @eernstg, @lrhn: could you look at the test cases and tell me what I've missed? (I was working off the excellent tables in [Class Modifiers] Overlap in lint and base/final subtyping restriction language#2871 but I'm sure some of the induction cases are going untested.)
  2. @MaryaBelanger, @bwilkerson: the docs are light and could use massaging minimally although ultimately I do think we want to link out to some place more authoritative; could you advise?

General comments welcome too. (I'm less concerned w/ implementation at this point and more on capturing the right test cases FWIW but happy to receive any feedback at all.)

Thanks in advance!

@coveralls
Copy link

coveralls commented Mar 1, 2023

Coverage Status

Coverage: 96.325% (+0.02%) from 96.306% when pulling bdb1539 on implicit_reopen into 3049702 on main.

Copy link
Member

@bwilkerson bwilkerson left a comment

Choose a reason for hiding this comment

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

One minor suggestion, but I thought the description was good.

I didn't look at the implementation.

lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
Copy link
Member

@srawlins srawlins left a comment

Choose a reason for hiding this comment

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

Just drive-bys.

test/rules/implicit_reopen_test.dart Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Outdated Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
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.

Commenting on the test cases:

I agree with @kallentu that it would be good to have cases where there is more than one step of implicit provision of class modifiers. E.g., class A is interface, sealed class B extends A is then implicitly interface, and and so es sealed class C extends B.

Similarly, being implicitly interface can propagate through any number of mixin applications (and that case also does not seem to be covered):

interface mixin M1 {}
mixin M2 {}
...
mixin Mk {}

sealed class C with M1, ... Mk {} // Implicitly `interface`.

@kallentu also mentioned the following case (and I don't think it's covered yet), which is the second half of the first rule in my ruleset:

interface class S {}
base class I {}
sealed class A extends S implements I {} // Implicitly `final`.

A couple of other cases I couldn't spot are these ones (that's the second rule):

base class I {}
sealed class A implements I {} // Implicitly `base`.

final class I2 {}
sealed class A2 implements I2 {} // Implicitly `base`.

sealed mixin /* or mixin class */ M implements I {} // Implicitly `base`.
sealed mixin /* or mixin class */ M2 implements I2 {} // Implicitly `base`.
sealed mixin on I {} // Implicitly `base`.
sealed mixin on I2 {} // Implicitly `base`.

test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Show resolved Hide resolved
@pq
Copy link
Member Author

pq commented Mar 21, 2023

Source and tests updated. Nothing will pass until a new analyzer is released so still WIP.

@pq
Copy link
Member Author

pq commented Mar 21, 2023

@eernstg, @kallentu : I added a handful of tests but would love for you to take a look... It looks like some of the cases we discussed above have been recently disallowed and will produce analyzer diagnostics (and so not a lint).

If you see negative tests I should implement please let me know too. I'd much rather under than over report!

@pq
Copy link
Member Author

pq commented Mar 21, 2023

(And needless to say, thank you all for your patience and perseverance. I think we're closing in!)

@pq
Copy link
Member Author

pq commented Mar 22, 2023

@bwilkerson, @kallentu, @eernstg: polite ping for a review... Hoping to get this in before the cut off. 🏁

Copy link
Member

@kallentu kallentu left a comment

Choose a reason for hiding this comment

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

I've exhausted my brain for test cases (which you've added already) so I'll leave whatever is missing to Erik.

I think this is how I imagined the initial implementation for the lint -- LGTM

lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
test/rules/implicit_reopen_test.dart Outdated Show resolved Hide resolved
@eernstg
Copy link
Member

eernstg commented Mar 22, 2023

Oops, I missed this one. I'll take a look within the next couple of hours.

@pq
Copy link
Member Author

pq commented Mar 22, 2023

No worries, @eernstg. Thanks so much!

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.

LGTM! Left a few comments.

lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Outdated Show resolved Hide resolved
lib/src/rules/implicit_reopen.dart Show resolved Hide resolved
@pq
Copy link
Member Author

pq commented Mar 22, 2023

Thanks again to everyone for all the feedback!

@pq pq merged commit 70de77d into main Mar 22, 2023
@pq pq deleted the implicit_reopen branch March 22, 2023 20:31
mockturtl added a commit to mockturtl/tidy that referenced this pull request May 20, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 23, 2023
* + implicit_reopen

* feedback

* docs

* class type aliases

* fmt

* fix description

* hoist

* --

* rebase

* revisit

* ++

* ++

* --

* ++

* + test

* //

* Fix dart-lang/linter#4165 by visiting SwitchPatternCase (dart-lang/linter#4169)

* Use deps.dev for OpenSSF scorecard results link (dart-lang/linter#4184)

* prefer_final_parameters tests (dart-lang/linter#4182)

* prefer_final_parameters tests

* --

* switch to the latest published version of the setup-dart action (dart-lang/linter#4186)

* test cleanup (dart-lang/linter#4185)

* Support analyzer 5.9.0 (dart-lang/linter#4188)

* - mixin

* rename

* rename

* Update lib/src/rules/implicit_reopen.dart

Co-authored-by: Erik Ernst <[email protected]>

* Update lib/src/rules/implicit_reopen.dart

Co-authored-by: Erik Ernst <[email protected]>

* Update lib/src/rules/implicit_reopen.dart

Co-authored-by: Erik Ernst <[email protected]>

* Update lib/src/rules/implicit_reopen.dart

Co-authored-by: Erik Ernst <[email protected]>

* Update lib/src/rules/implicit_reopen.dart

Co-authored-by: Erik Ernst <[email protected]>

* fdbk

---------

Co-authored-by: Sam Rawlins <[email protected]>
Co-authored-by: Parker Lougheed <[email protected]>
Co-authored-by: Devon Carew <[email protected]>
Co-authored-by: Erik Ernst <[email protected]>
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.

implement implicit_reopen
9 participants