-
Notifications
You must be signed in to change notification settings - Fork 81
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
Stateroot-enabled GetBlock #2583
Conversation
Regular methods need this, because it'll be packed into parameters, but inlined ones should deal with it in inlining code itself because method receiver will be some local (aliased) variable anyway.
Codecov Report
@@ Coverage Diff @@
## master #2583 +/- ##
==========================================
- Coverage 84.93% 84.63% -0.30%
==========================================
Files 297 297
Lines 37304 37491 +187
==========================================
+ Hits 31683 31730 +47
- Misses 4260 4379 +119
- Partials 1361 1382 +21
Continue to review full report at Codecov.
|
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.
Ugh, I'm not able to properly review the compiler-related code...
pkg/compiler/codegen.go
Outdated
@@ -915,6 +915,9 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { | |||
} | |||
case *ast.SelectorExpr: | |||
name, isMethod := c.getFuncNameFromSelector(fun) | |||
if isMethod && name[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.
It seems this branch is not covered.
Also, usage analysis should have similar checks, so can we move this if
inside of getFuncNameFromSelector
?
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.
Let me think about it, the branch itself should be covered by the TestInlinedMethod
(it uses pointer receiver).
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.
It's ironic that this is the only place where we do care about isMethod
, but probably it makes sense to return stripped name anyway, shouldn't affect current users in any way and any other method-aware code will probably need that too.
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.
However, we use the type of a local variable, not of a function formal receiver. I think using z = &inline.T{}
should cover this.
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.
Yep, that works, added another test and reorder commits.
Notice that this doesn't differentiate between (*T) and (T) receivers always treating them as is. But we have the same problem with arguments now and the number of inlined calls is limited, usually we want this behavior.
c.funcs contains function names using base types, while methods can be defined on pointers and the value returned from c.getFuncNameFromSelector will have an asterisk. We can't have the same name used for (*T) and (T) methods, so just stripping the asterisk allows to get the right one.
And add compiler/interop support for this.
Turned out to be more of a compiler problem than interop one.