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-7485) BUG! exception in phase 'semantic analysis'... when trying to call instance method as default for a constructor parameter
Date Thu, 02 Jul 2015 10:39:05 GMT

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

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

GitHub user paulk-asert opened a pull request:

    https://github.com/apache/incubator-groovy/pull/50

    GROOVY-7485: BUG! exception in phase 'semantic analysis'... when tryi…

    …ng to call instance method as default for a constructor parameter

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

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

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

    https://github.com/apache/incubator-groovy/pull/50.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 #50
    
----
commit f53eb3411a4f9ffa574e8dd094ab5f65c3d7833e
Author: paulk <paulk@asert.com.au>
Date:   2015-07-02T10:35:16Z

    GROOVY-7485: BUG! exception in phase 'semantic analysis'... when trying to call instance
method as default for a constructor parameter

----


> BUG! exception in phase 'semantic analysis'... when trying to call instance method as
default for a constructor parameter
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7485
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7485
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.3
>         Environment: Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
> Seen in java 7 too.
>            Reporter: John Flinchbaugh
>            Priority: Minor
>
> % groovyc StaticDefault.groovy # the code below
> {code}
> class StaticDefault {
>     def name 
>     StaticDefault(name = getName()) {
>         this.name = name
>     }
>     private getName() {
>         'name'
>     }
> }
> {code}
> And see this stacktrace:
> {code}
> >>> a serious error occurred: BUG! exception in phase 'semantic analysis' in
source unit 'StaticDefault.groovy' unexpected NullpointerException
> >>> stacktrace:
> BUG! exception in phase 'semantic analysis' in source unit 'StaticDefault.groovy' unexpected
NullpointerException
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1057)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:588)
> 	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:566)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:543)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:522)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:59)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:215)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:148)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:178)
> 	at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:162)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
> 	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
> Caused by: java.lang.NullPointerException
> 	at org.codehaus.groovy.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:84)
> 	at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:70)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:129)
> 	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
> 	at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:79)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:119)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1079)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
> 	at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:42)
> 	at org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:209)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
> 	... 15 more
> {code}
> Switching the method used for the default to a static method (private static getName()...)fixes
the problem, but I'm guessing you likely wanted to give a better message out of the compiler.



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

Mime
View raw message