Skip to content

Add support for @Unsafe to analyzer #40431

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

Closed
wants to merge 2 commits into from

Conversation

mehmetf
Copy link
Contributor

@mehmetf mehmetf commented Feb 1, 2020

Add support for @Unsafe annotation as isUnsafe and hasUnsafe.

See: #40429 for the definition of the annotation.

@mehmetf mehmetf requested a review from pq February 1, 2020 00:05
@@ -2392,6 +2392,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
/// The name of the top-level variable used to mark a class as being sealed.
static const String _SEALED_VARIABLE_NAME = "sealed";

/// The name of the top-level variable used to mark a method as unsafe.
Copy link
Member

Choose a reason for hiding this comment

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

Is this just methods or other members?

Copy link
Member

Choose a reason for hiding this comment

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

nit: Unsafe is a class, not a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -1,3 +1,6 @@
## 0.39.6
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be 0.39.5?

/cc @stereotype441

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I am not sure what -dev means....

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.

We obviously need to resolve the question of where the annotation lives before committing this.

@@ -2392,6 +2392,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
/// The name of the top-level variable used to mark a class as being sealed.
static const String _SEALED_VARIABLE_NAME = "sealed";

/// The name of the top-level variable used to mark a method as unsafe.
Copy link
Member

Choose a reason for hiding this comment

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

nit: Unsafe is a class, not a variable.

@@ -2540,6 +2543,12 @@ class ElementAnnotationImpl implements ElementAnnotation {
element.name == _SEALED_VARIABLE_NAME &&
element.library?.name == _META_LIB_NAME;

@override
bool get isUnsafe =>
element is PropertyAccessorElement &&
Copy link
Member

Choose a reason for hiding this comment

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

This seems wrong to me. I would have expected that it would be a ClassElement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hint: I don't know what I am doing :-) So thanks for all the help!

I have not setup my environment to test this yet. When the annotation is agreed upon and pushed to master, I can tinker with this.

@mehmetf
Copy link
Contributor Author

mehmetf commented Feb 17, 2020

Closing this PR as there's a better proposal being discussed.

@mehmetf mehmetf closed this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants