GROOVY-11986#2510
Merged
Merged
Conversation
…ny get(X) where X is a supertype of String
…ny get(X) where X is a supertype of String (test)
There was a problem hiding this comment.
Pull request overview
This PR addresses GROOVY-11986 by tightening Groovy’s generic property-getter (genericGetMethod) detection so that only get(String) is treated as the generic getter, preventing unrelated single-argument get(X) methods (e.g., get(Serializable), get(Object)) from shadowing propertyMissing.
Changes:
- Update
MetaClassImpl.checkIfStdMethodto registergenericGetMethodonly when the parameter type is exactlyString. - Add a new regression test suite covering inheritance/trait cases where
get(Serializable)/get(Object)must not hijack dynamic property access. - Add sanity tests ensuring
get(String)still works as the generic getter and wins over broader inheritedget(Serializable).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/groovy/lang/MetaClassImpl.java | Restricts generic getter registration to get(String) to preserve correct propertyMissing behavior. |
| src/test/groovy/bugs/Groovy11986.groovy | Adds regression + sanity tests validating property resolution behavior with inherited/trait get(...) methods. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.