-
Notifications
You must be signed in to change notification settings - Fork 194
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
Extend type inferencing of dynamic field or property assigned in constructor or initialization method #1080
Comments
This is testable for assignment in constructor or initializer block. If that looks good, an additional change will be made to support post-construct and other well-known initializer methods (like Spock's |
Thanks. Since there is no 100% guarantee that the value will not be overwritten with the value of another type from anywhere anyway, it would make sense not to worry too much about false inference and to look for the assignment anywhere, not only in the well-known initializer methods. For example, there may be two Spock tests that assign the value in |
Did you have a chance to test what was implemented? This is not one of those 100% enhancements. Only common cases are going to be properly supported. See also #1056 (odd switch case structures will not infer properly). |
It seems that the correct type is inferred only in the simple way where assignment is made at the location of declaration. Maybe it can be improved?
It does not work, for example, when
def
variable is assigned in Spock'ssetup()
.Related article from 2009: http://contraptionsforprogramming.blogspot.com/2009/11/how-type-inferencing-for-groovy-in.html
The text was updated successfully, but these errors were encountered: