Skip to content

GROOVY-11823: try super.propertyMissing(name) before outer class#2360

Closed
eric-milles wants to merge 1 commit intomasterfrom
GROOVY-11823
Closed

GROOVY-11823: try super.propertyMissing(name) before outer class#2360
eric-milles wants to merge 1 commit intomasterfrom
GROOVY-11823

Conversation

@eric-milles
Copy link
Copy Markdown
Member

I'm on the fence about this one. On the off chance an inner class' super class provides "methodMissing" or "propertyMissing", all inner class non-static dispatch methods need to call super.methodMissing(name,args) or super.propertyMissing(name) or super.propertyMissing(name,value). The super class must throw a MissingMethodException or MissingPropertyException for the caller to be able to fall back on current behavior.

class Outer {
  class Inner {
    // ...
    Object methodMissing(String name, Object args) {
      if (!"methodMissing".equals(name))
      try {
        super.methodMissing(name, args)
      } catch (MissingMethodException ignore) {
      }
      try {
        // outerClass.name(args)
      } catch (MissingMethodException notFound) {
        throw new MissingMethodException(notFound.method, this, notFound.arguments)
      }
    }
  }
}

The "ignore" exception could be thrown for no super class "methodMissing" or no "name" support, which is not ideal. In the event the super class does not supply "methodMissing", there is a call to this method which is why a guard was added (to prevent stack overflow). :(

@eric-milles
Copy link
Copy Markdown
Member Author

Adding the super class dispatch could be limited to cases where the super class explicitly declares the required method.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.0648%. Comparing base (f773c06) to head (969ca9c).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2360        +/-   ##
==================================================
+ Coverage     67.0511%   67.0648%   +0.0137%     
- Complexity      29433      29442         +9     
==================================================
  Files            1382       1382                
  Lines          116192     116207        +15     
  Branches        20464      20467         +3     
==================================================
+ Hits            77908      77934        +26     
+ Misses          31806      31801         -5     
+ Partials         6478       6472         -6     
Files with missing lines Coverage Δ
...s/groovy/classgen/InnerClassCompletionVisitor.java 91.5493% <100.0000%> (+1.1453%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eric-milles
Copy link
Copy Markdown
Member Author

I went with this: ed63edb

@eric-milles eric-milles closed this Feb 3, 2026
@eric-milles eric-milles deleted the GROOVY-11823 branch February 3, 2026 22:01
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