[
https://issues.apache.org/jira/browse/GROOVY-11273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17805408#comment-17805408
]
Paul King edited comment on GROOVY-11273 at 1/11/24 7:17 AM:
-------------------------------------------------------------
Thanks for spotting that. We previously didn't support native default methods
on interfaces and didn't hook in the final variable analyzer when we added that
support:
[https://github.com/apache/groovy/commit/dbc74da621e9f9687264711d1d80ea9c444216cd]
was (Author: paulk):
Thanks for spotting that. We previously didn't support default methods and
didn't hook in the final variable analyzer when we added that support:
https://github.com/apache/groovy/commit/dbc74da621e9f9687264711d1d80ea9c444216cd
> Fail to identify updates on final variables declared in default methods
> -----------------------------------------------------------------------
>
> Key: GROOVY-11273
> URL: https://issues.apache.org/jira/browse/GROOVY-11273
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Paul King
> Priority: Minor
> Labels: default-methods
> Fix For: 5.0.0-alpha-5
>
>
> I have the following ill-typed program:
> {code}
> interface Test {
> default void test() {
> final int x = 1;
> x = 2;
> }
> }
> {code}
> h3. Actual behavior
> The code compiles successfully
> h3. Expected behavior
> Code rejected with:
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> test.groovy: 4: The variable [x] is declared final but is reassigned
> . At [4:5] @ line 4, column 5.
> x = 2;
> ^
> 1 error
> {code}
> Tested against master (commit: 3cd76364f772250324f5729ef93ffd76fbdd2b79)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)