You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/09/13 10:25:00 UTC

[jira] [Commented] (GROOVY-7721) Static type checking fails when compiling against a Java8 interface with inherited methods

    [ https://issues.apache.org/jira/browse/GROOVY-7721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164445#comment-16164445 ] 

ASF GitHub Bot commented on GROOVY-7721:
----------------------------------------

GitHub user avafanasiev opened a pull request:

    https://github.com/apache/groovy/pull/599

    GROOVY-7721: Static type checking fails when compiling against a Java interface call

    Arrays is also covariants in java, so they should be also compared. 
    Can't find exact documentation, but  JLS 15.12.2.5 says:
    – Otherwise, if all the maximally specific methods are abstract or default, and
    the signatures of all of the maximally specific methods have the same erasure
    (§4.6), then the most specific method is chosen arbitrarily among the subset
    of the maximally specific methods that have the most specific return type.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/avafanasiev/groovy master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/599.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #599
    
----
commit 98d82aeff501cd996f1a9aebfae793160c8d3cfe
Author: alexey.afanasiev <al...@jetbrains.com>
Date:   2017-09-13T10:14:58Z

    GROOVY-7721: Static type checking fails when compiling against a Java8 interface with inherited methods

----


> Static type checking fails when compiling against a Java8 interface with inherited methods
> ------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7721
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7721
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 2.4.0
>            Reporter: Peter Gromov
>
> Create classes.java:
> {code}
> interface I {
>     R[] method();
> }
> interface I2 extends I {
>     R2[] method();
> }
> interface R {}
> interface R2 extends R {}
> {code}
> compile it with JDK 8 javac.
> Then create usage.groovy:
> {code}import groovy.transform.CompileStatic
> @CompileStatic
> class Gr {
>     R2[] x(I2 i) {
>        return i.method();
>     }
> }
> {code}
> Compile it with groovyc (also run with Java8) with the classes from previous compilation in the classpath. Compilation fails:
> {code}
> usage.groovy: 6: [Static type checking] - Reference to method is ambiguous. Cannot choose between [R2[] I2#method(), R[] I2#method()]
>  @ line 6, column 15.
>           return i.method();
>                  ^
> 1 error
> {code}
> Originally reported as https://youtrack.jetbrains.com/issue/IDEA-148973



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