You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniil Ovchinnikov (JIRA)" <ji...@apache.org> on 2018/06/22 12:34:00 UTC

[jira] [Created] (GROOVY-8660) Unexpected MethodSelectionException with implicit null argument

Daniil Ovchinnikov created GROOVY-8660:
------------------------------------------

             Summary: Unexpected MethodSelectionException with implicit null argument
                 Key: GROOVY-8660
                 URL: https://issues.apache.org/jira/browse/GROOVY-8660
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.5.0, 2.4.15, 3.0.0-alpha-2
            Reporter: Daniil Ovchinnikov


{code:groovy}
class OnlySingle {
    def foo(a) { "single param: $a" }
}

println new OnlySingle().foo()
// as expected: 'single param: null'


class OnlyVararg {
    def foo(a, ... b) { "vararg param: $a, $b" }
}

println new OnlyVararg().foo()
// as expected: 'MME: No signature of method: OnlyVararg.foo() is applicable for argument types: () values: []'

class Both {
    def foo(a) { "single param: $a" }
    def foo(a, ... b) { "vararg param: $a, $b" }
}

println new Both().foo()
// unexpected:
// MethodSelectionException: Could not find which method foo() to invoke from this list:
//  public java.lang.Object Both#foo(java.lang.Object)
//  public transient java.lang.Object Both#foo(java.lang.Object, [Ljava.lang.Object;)
{code}

If the exception is expected then {{OnlyVararg}} case should work too.
If the exception is unexpected then {{Both#foo(Object)}} should be selected.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)