You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2018/08/18 08:50:00 UTC

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

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

Daniel Sun resolved GROOVY-8405.
--------------------------------
       Resolution: Fixed
         Assignee: Daniel Sun
    Fix Version/s: 2.5.3
                   3.0.0-alpha-4

The issue is fixed. Here is the test: 

https://github.com/apache/groovy/commit/680317fc2c4e9cdf2707b386e5cc5f49f670bab9

> 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
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 3.0.0-alpha-4, 2.5.3
>
>
> 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
(v7.6.3#76005)