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 2018/09/22 16:16:00 UTC
[jira] [Commented] (GROOVY-8327) Parser regression. Can't access
static instance method before class is constructed
[ https://issues.apache.org/jira/browse/GROOVY-8327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16624732#comment-16624732 ]
ASF GitHub Bot commented on GROOVY-8327:
----------------------------------------
GitHub user danielsun1106 opened a pull request:
https://github.com/apache/groovy/pull/801
GROOVY-8327: Parser regression. Can't access static instance method b…
…efore class is constructed
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/danielsun1106/groovy GROOVY-8327
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/801.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 #801
----
commit 4d285954134a45c88257aaa7b24775ea1f3a6a71
Author: danielsun1106 <re...@...>
Date: 2018-09-22T15:49:06Z
GROOVY-8327: Parser regression. Can't access static instance method before class is constructed
----
> Parser regression. Can't access static instance method before class is constructed
> ----------------------------------------------------------------------------------
>
> Key: GROOVY-8327
> URL: https://issues.apache.org/jira/browse/GROOVY-8327
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.6.0-alpha-1, 3.0.0-alpha-3, 2.5.2
> Environment: groovc command line on linux
> Reporter: Isaac Dooley
> Priority: Major
>
> The parser in 2.5, 2.6, 3.0 gives a MultipleCompilationErrorsException on code that compiled successfully in 2.4
> {code:java|title=Code that fails to compile on 2.6.0-alpha-1}
> class A {
> static String g() { }
> A() {
> this({g()}) // It is ok to create a closure that calls g() in a constructor, but not if it is being passed into this().
> }
> A(a) { }
> }
> {code}
> {code:java|title=compilation error message}
> $ groovyc test.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 4: Can't access instance method 'g' before the class is constructed
> @ line 4, column 15.
> this({g()}) // It is ok to create a closure that calls g() in a constructor, but not if it is being passed into this().
> ^
> 1 error
> {code}
> My opinion is that groovy should allow users to call a static method inside a constructor before the instance has been fully constructed, but I'm not aware of the details of why this is disallowed in 2.6.0-alpha-1.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)