Skip to content

GROOVY-11986#2510

Merged
paulk-asert merged 2 commits into
apache:masterfrom
paulk-asert:GROOVY-11986
May 3, 2026
Merged

GROOVY-11986#2510
paulk-asert merged 2 commits into
apache:masterfrom
paulk-asert:GROOVY-11986

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

No description provided.

…ny get(X) where X is a supertype of String (test)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.checkIfStdMethod to register genericGetMethod only when the parameter type is exactly String.
  • 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 inherited get(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.

@paulk-asert paulk-asert changed the title Groovy 11986 GROOVY-11986 May 3, 2026
@paulk-asert paulk-asert merged commit a4caaa4 into apache:master May 3, 2026
25 checks passed
@paulk-asert paulk-asert deleted the GROOVY-11986 branch May 3, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants