Skip to content

Conversation

@eric-milles
Copy link
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
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

codecov-commenter commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.0200%. Comparing base (2fc8212) to head (6b526a9).

Files with missing lines Patch % Lines
src/main/java/groovy/lang/MetaClassImpl.java 0.0000% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2360        +/-   ##
==================================================
+ Coverage     67.0089%   67.0200%   +0.0111%     
- Complexity      29381      29387         +6     
==================================================
  Files            1382       1382                
  Lines          116680     116695        +15     
  Branches        20466      20469         +3     
==================================================
+ Hits            78186      78209        +23     
+ Misses          32050      32046         -4     
+ Partials         6444       6440         -4     
Files with missing lines Coverage Δ
...s/groovy/classgen/InnerClassCompletionVisitor.java 91.6667% <100.0000%> (+1.1194%) ⬆️
src/main/java/groovy/lang/MetaClassImpl.java 78.4994% <0.0000%> (ø)

... 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.

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