[
https://issues.apache.org/jira/browse/GROOVY-9363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17019016#comment-17019016
]
Eric Milles edited comment on GROOVY-9363 at 1/19/20 7:12 PM:
--------------------------------------------------------------
The parser currently sees "super \{ ... \}" as a method call expression
(expression switch selects
{{org.codehaus.groovy.antlr.AntlrParserPlugin#methodCallExpression}}). A
"this(...)" or "super(...)" call is recognized separately by
{{org.codehaus.groovy.antlr.AntlrParserPlugin.specialConstructorCallExpression}}.
was (Author: emilles):
The parser currently sees "super { ... }" as a method call expression
(expression switch selects
{{org.codehaus.groovy.antlr.AntlrParserPlugin#methodCallExpression}}). A
"this(...)" or "super(...)" call is recognized separately by
{{org.codehaus.groovy.antlr.AntlrParserPlugin.specialConstructorCallExpression}}.
> False "Constructor call must be the first statement in a constructor"
> ---------------------------------------------------------------------
>
> Key: GROOVY-9363
> URL: https://issues.apache.org/jira/browse/GROOVY-9363
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.8
> Reporter: Björn Kautler
> Priority: Major
>
> Given this script:
> {code:groovy}
> import java.util.function.Supplier
> class Foo {
> Foo(Supplier<?> supplier) {
> }
> }
> class Bar extends Foo {
> Bar() {
> super { null }
> }
> }
> new Bar()
> {code}
> I'd expect everything to be ok, but the compiler complains that "Constructor
> call must be the first statement in a constructor".
> Using {{super(\{ null \})}} instead works fine.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)