You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Nathan Harvey (JIRA)" <ji...@apache.org> on 2017/12/07 20:36:00 UTC

[jira] [Created] (GROOVY-8405) Inherited methods with default parameters cause cause static compilation to fail

Nathan Harvey created GROOVY-8405:
-------------------------------------

             Summary: Inherited methods with default parameters cause cause static compilation to fail
                 Key: GROOVY-8405
                 URL: https://issues.apache.org/jira/browse/GROOVY-8405
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.5.0-beta-1
            Reporter: Nathan Harvey
            Priority: Critical


Given a super type with a method that has a default argument:

{code:groovy}
@CompileStatic
class SuperType {
	void sample(String string, Integer arg=0) {}
}
{code}

And a subclass that extends the method, but omits the optional parameters:
{code:groovy}
@CompileStatic
class SubType extends SuperType {
	@Override
	void sample(String string) {}
}
{code}

Static type checking fails to pick which method to call in the following code:
{code:groovy}
@CompileStatic
class BrokenMethods {
	public static void main(String[] args) {
		new SubType().sample('hi')
	}
}
{code}

The error message is:
{code}
Reference to method is ambiguous. Cannot choose between [void codes.nom.broken.SubType#sample(java.lang.String), void codes.nom.broken.SubType#sample(java.lang.String)]
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)