groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7865) Better error message in the presence of Generics arity errors
Date Thu, 23 Jun 2016 09:32:16 GMT

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

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

GitHub user paulk-asert opened a pull request:

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

    GROOVY-7865: Better error message and earlier detection of Generics errors

    reworked version

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

    $ git pull https://github.com/paulk-asert/groovy groovy7865b

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

    https://github.com/apache/groovy/pull/353.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 #353
    
----
commit 2b8d488f0519add9aef73f59d998769f8808cbfe
Author: paulk <paulk@asert.com.au>
Date:   2016-06-17T08:38:25Z

    GROOVY-7865: Better error message in the presence of Generics arity errors (spike)

----


> Better error message in the presence of Generics arity errors
> -------------------------------------------------------------
>
>                 Key: GROOVY-7865
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7865
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Paul King
>
> Currently there are many places in the codebase which make assumptions that they are
working with valid generics information. Generics information is checked but not until the
classgen phase. Consequently, we get a very uninformative ArrayIndexOutOfBoundsException from
the compiler - either along with or instead of the subsequent generics checking. These are
all examples which should fail compilation since I have intentionally tried to instantiate
the generics type with an incorrect number of parameters. It is just the error message which
is not currently useful and masking the subsequent message that would occur had not the exception
got in the way. 
> Example with TraitComposer:
> {code}
> class MyNames implements Queue<Integer, String> { }
> // java.lang.ArrayIndexOutOfBoundsException: 1
> // TraitComposer calls GenericsUtils.parameterizeType()
> // which calls GenericsUtils.createGenericsSpec()
> {code}
> Example with StaticTypeCheckingVisitor:
> {code}
> @CompileStatic
> def foo() {
>   List<String> ss = new LinkedList<Integer, String>()
> }
> // => java.lang.ArrayIndexOutOfBoundsException: 1
> {code}
> Example with Verifier:
> {code}
> class MyNames extends Queue<Integer, String> { }
> {code}
> which gives
> {noformat}
> 2 compilation errors:
> The class java.util.Queue refers to the class java.util.Queue and uses 2 parameters,
but the referred class needs 1
>  at line: 5, column: 23
> Exception thrown
> java.lang.ArrayIndexOutOfBoundsException: 1
> 	at org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec(GenericsUtils.java:410)
> {noformat}
> So we get one error from the generics checking but then continue on to the Verifier.
> I suspect the fix for this is to move just the arity checking part of that visitor to
an earlier phase.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message