You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Mauro Molinari (Jira)" <ji...@apache.org> on 2020/04/24 09:26:00 UTC

[jira] [Created] (GROOVY-9523) MissingMethodException when referencing a private enum method

Mauro Molinari created GROOVY-9523:
--------------------------------------

             Summary: MissingMethodException when referencing a private enum method
                 Key: GROOVY-9523
                 URL: https://issues.apache.org/jira/browse/GROOVY-9523
             Project: Groovy
          Issue Type: Bug
          Components: groovy-runtime
    Affects Versions: 2.5.11
            Reporter: Mauro Molinari


Consider this Groovy class:

 

{code:groovy}
package test64

import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic

@CompileStatic
class Test64 {

	@CompileDynamic
	static enum ShippingAddressSynchType {
		ACCOUNTING {
			@Override
			void synch(Test64 customer) {
				truncate('foo', 2)
			}
		};

		void synch(Test64 customer) { }

		private String truncate(String input, int maxLength) {
			if(!input)
				return input
			if(input.length() > maxLength)
				input = input[0..maxLength - 1]
			return input
		}
	}
}
{code}

and a Java class to run it:

{code:java}
package test64;

import test64.Test64.ShippingAddressSynchType;

public class Test64Main {

	public static void main(String[] args) {
		Test64 t = new Test64();
		ShippingAddressSynchType.ACCOUNTING.synch(t);
	}
}
{code}

If you run this code, you'll get:

{noformat}
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: test64.Test64$ShippingAddressSynchType$1.truncate() is applicable for argument types: (String, Integer) values: [foo, 2]
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:83)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:156)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176)
        at test64.Test64$ShippingAddressSynchType$1.synch(Test64.groovy:14)
        at test64.Test64Main.main(Test64Main.java:9)
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)