-
Notifications
You must be signed in to change notification settings - Fork 295
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
Disallow using In/Out structs with From/As annotations #1068
Conversation
I understand disallowing |
Codecov Report
@@ Coverage Diff @@
## master #1068 +/- ##
=======================================
Coverage 98.52% 98.53%
=======================================
Files 39 39
Lines 2992 2996 +4
=======================================
+ Hits 2948 2952 +4
Misses 37 37
Partials 7 7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Leaving couple of comments. Also lint seems to have failed? (try running make lint
)
annotated.go
Outdated
if !dig.IsOut(reflect.New(ft.Out(i)).Elem().Interface()) { | ||
continue | ||
} | ||
if len(ann.ResultTags) > 0 || len(ann.As) > 0 || len(ann.From) > 0 { |
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 is actually the old behavior we had for As/From annotations with Out/In structs, which is the safest way to go before easing up on this requirement. However, I agree with Jacob that this is a little overly restrictive, considering As annotation does not affect parameters of a constructor, and From annotation does not affect results of a constructor at all. So we could probably let users use As and From annotations with In and Out structs, respectively.
I'll leave it up to you to decide on how you'd like to proceed.
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.
Makes sense.
Have removed this unintended restriction and to allow fx.Out struct with From annotation and fx.In struct with As annotation.
…In struct with As annotation
Agreed @JacobOaks . Thanks for calling this out, I have made the necessary edits. |
Thanks @tchung1118. Have made the required edits and fixed lint errors as well. |
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 LGTM but I'll wait to see if @tchung1118 has any outstanding comments.
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.
LGTM
Co-authored-by: JacobOaks <jacoboaks.8@gmail.com>
Thanks for correcting the documentation and approving the PR @sywhang |
In #1053, we eased up the requirement for function signature for applying annotations to allow using In/Out structs with ResultTags/ParamTags. This had an unintended change in behavior where users are now able to use In/Out structs with From/As annotations. For example, the below code used to error out:
Currently the code above applies the As annotation to ABar field and transforms the target function's signature accordingly. However, this was an unintended change in behavior, and we should have a design discussion about whether we actually want this before cutting a new release. Since it will require a breaking change to disable this after a new release is cut, I think the safe approach is to disable this for now and enable it after having decided that this is indeed what we want.
Fixes #1060