-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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....
There was a problem hiding this 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. |
There was a problem hiding this comment.
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 && |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
Closing this PR as there's a better proposal being discussed. |
Add support for
@Unsafe
annotation asisUnsafe
andhasUnsafe
.See: #40429 for the definition of the annotation.