-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Lint unrelated_type_equality_checks
no longer recognizes Int64
, Int32
.
#58939
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
Comments
Oh! This is a great heads-up. When is the refactored package scheduled to be released? If it's before Dart 3.0, we should hustle to get a fix in today (or cherry-picked) for 2.19. |
Ah. Chatting with @devoncarew, it sounds like this issue is blocking a roll of |
Yup, from https://github.com/dart-lang/sdk/blob/main/DEPS#L132, the roll issue is b/260609190. |
See: https://github.com/dart-lang/linter/issues/3868 (This should also unblock the fixnum internal roll.) Change-Id: I9af710b075c6280ee55153c559f91ac6a0b21f3d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273007 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
Solution looks good. Should work even if we end up doing different implementations for different platforms, so there'll be more than one |
* updates `unrelated_type_equality_checks` for `pkg:fixnum` restructuring * updates `prefer_equal_for_default_values` to not report for SDKs >=2.19, where this lint is now an analyzer diagnostic. (Note that these changes landed *before* the release cut-off. 😬) Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/274481 Fixes: https://github.com/dart/sdk/issues/56781234 --- pull `unrelated_type_equality_checks` fix See: https://github.com/dart-lang/linter/issues/3868 (This should also unblock the fixnum internal roll.) Change-Id: I9af710b075c6280ee55153c559f91ac6a0b21f3d linter 1.31.0 Cherry-picks update of `prefer_equal_for_default_values` to be a no-op in SDKs `>=2.19`. See: dart-archive/linter#3865 Change-Id: I2669f0279a0913bc8b3c5b0501a9869608883a14 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274481 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
The lint
unrelated_type_equality_checks
has special-casing recognizingInt64
andInt32
frompackage:fixnum
, to allow them to be compared to integers (which are otherwise an unrelated type).This recognition fails after a refactoring of
package:fixnum
, which moved the classes into individual libraries, instead of usingpart
files.To Reproduce
Use tip-of-tree code from https://github.com/dart-lang/fixnum
Try to do
if (FixNum(1) == 1) ...
with the lint enabled. This used to not give a warning. Now it does.Expected behavior
The
Int64
andInt32
classes should still be recognized and special cased.Additional context
The relevant code is:
This approach depends on the package not changing, which is a fragile assumption to have for a separate package.
Consider instead checking whether the the classes are named
Int32
orInt64
, and the path to the library starts withpackage:fixnum/
. That should cover most potential future refactorings of the package as well, because all it checks for is a class with one of those names provided bypackage:fixnum
, without assuming anything about the internal structure of the package.(That will make the lint harder to test, since you cannot just create a library with name
fixnum
and anInt64
type. Maybe retain the library name check as well, or change it to.name == 'fixnum_for_testing'
, so you can still trigger the lint without depending onpackage:fixnum
. On the other hand, depending on the realpackage:fixnum
for testing, as a dev-dependency, might help detecting if the lint breaks again.)The text was updated successfully, but these errors were encountered: