[ 
https://issues.apache.org/jira/browse/GROOVY-8405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nathan Harvey updated GROOVY-8405:
----------------------------------
    Description: 
Given a super type with a method that has a default argument:

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

And a subclass that extends the method, but omits the optional parameters:
{code}
@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}
@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}

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

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

And a subclass that extends the method, but omits the optional parameters:
{code}
@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}


> 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: Minor
>
> Given a super type with a method that has a default argument:
> {code}
> @CompileStatic
> class SuperType {
>       void sample(String string, Integer arg=0) {}
> }
> {code}
> And a subclass that extends the method, but omits the optional parameters:
> {code}
> @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}
> @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)

Reply via email to