-
Notifications
You must be signed in to change notification settings - Fork 171
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[macros] 馃煛 support for annotate_overrides
#4925
Comments
annotate_overrides
annotate_overrides
https://dart-review.googlesource.com/c/sdk/+/362660 probably unblock this. |
What is the intended behavior for Should an Or rather, this sounds like a lint where only the final fully-augmented result matters. The |
I agree and I think that's should be a general principle for any tooling checking for the absence of an annotation. Here's my reasoning. According to the spec (https://github.com/dart-lang/language/blob/main/working/augmentation-libraries/feature-specification.md#metadata-annotations-and-macro-applications), metadata annotations and macro applications are cumulative across the base declaration and the augmentations. So semantically, having an I suspect that in this case the intent of the work item is to only report the lint on the base declaration. That would also mean that our existing fix will continue to work without changes.
I believe the goal of the lint is to ensure that (a) users are aware if a method starts to override a method added to a supertype, and (b) that users will be aware if a method that was added in order to override a method from a supertype is no longer needed because the method has been removed. But I do think that it's an interesting UX question: will it be confusing to users to have annotations on an augmentation and hence not visible when looking at the base declaration? If so, we might want to consider ways for the IDE tooling to mitigate that confusion. |
I think only the base declaration. My sense is that we should not lint on augmented fields or methods. (Just on fields and methods added by augmentation classes.)
That's my understanding too. |
annotate_overrides
annotate_overrides
Fixes: dart-lang/linter#4925 Change-Id: I7b9a3b5ab2c372bb29f990852edbf86ea49cd75b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362302 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
Fixed w/ dart-lang/sdk@d3d3efb |
I'd probably want to allow In particular, a macro can add a super-interface, and it should be able to add the appropriate override too. @someMacro
class C {
int get length => 42;
}
// from macro
augment class C implements Iterable<String> {
// ...
@override
augment int get length;
} |
Agreed. Currently, the above code will (wrongly) flag the initial declaration of |
See also: dart-lang/sdk#55579 -- If |
We should definitely allow it. The question is whether the lint should require it. I'm inclined to say "no" because the language doesn't require it and it doesn't seem unreasonable for users to not want to duplicate annotations. By "duplicate" I mean that, as far as I understand, writing (with the right boilerplate around it) class C {
@override
String toString() {}
}
augment class C {
@override
augment String toString() {}
} means that the method For @Deprecated('as of 2.12')
@Deprecated('as of 3.1')
void f() {} where the duplication seems harmless, it raises questions of what the analyzer should show in the diagnostic when The point of all that being that we don't know what the community will want to do stylistically, and I don't think we want to make the lint enforce one choice or the other at this point. Maybe a different lint to enforce duplication would make sense if that becomes a common pattern. |
Adds a failing test for the case where a `hasOverride` getter should consider augmentations. See: dart-lang/linter#4925 Change-Id: I8d7e8f145d630abbef438a79076820613a801940 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364623 Commit-Queue: Phil Quitslund <pquitslund@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
annotate_overrides
annotate_overrides
Blocked on WIP in analyzer.
https://dart-review.googlesource.com/c/sdk/+/362302
/fyi @scheglov
The text was updated successfully, but these errors were encountered: