groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (GROOVY-8188) Unpredictable behavior - Compiler error: groovyc: You are not allowed to override the final method
Date Thu, 18 May 2017 07:36:04 GMT

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

Paul King edited comment on GROOVY-8188 at 5/18/17 7:35 AM:
------------------------------------------------------------

Ah, okay, I didn't see it before. It's a bridge method added for a covariant return type.
The ClassCompletionVerifier doesn't seem to look at return type which seems wrong to me. Here
is a smaller example which exhibits the problem:
{code}
interface Foo {
  Foo foo()
}

abstract class FooImpl implements Foo {
  final FooImpl foo() { null }
}

class Main extends FooImpl implements Foo { }

assert !new Main().foo()
{code}
Note that the {{implements Foo}} in {{Main}} is redundant but required to produce the error.


was (Author: paulk):
Ah, okay, I didn't see it before. It's a bridge method added for a covariant return type.
The ClassCompletionVerifier doesn't seem to look at return type which seems wrong to me. Here
is a smaller example which exhibits the problem:
{code}
interface Foo {
  Foo foo()
}

abstract class FooImpl implements Foo {
  final FooImpl foo() { null }
}

class Main extends FooImpl implements Foo { }

assert !new Main().foo()
{code}
Note that the {{implements Foo}} is redundant but required to produce the error.

> Unpredictable behavior - Compiler error: groovyc: You are not allowed to override the
final method
> --------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8188
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8188
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.11
>         Environment: Windows
>            Reporter: Abbas Gadhia
>         Attachments: groovyc.7z
>
>
> I'm trying to extend from an abstract class and override one of its abstract methods.
Another "final" concrete method of the same name exists in the abstract class.
> When I compile, it complains that i cannot override the method marked as final, however
i've only overriden the abstract method, and not the "final" one.
> This issue is sporadic. The error pops up and goes after several retries
> I've attached a simple project that reproduces this issue. The error may or may not happen
the first time. Tweaking the code here and there, gets the issue to pop up
> Here's a sample of the error message
> bq. Error:Groovyc: You are not allowed to override the final method copy(org.apache.calcite.plan.RelTraitSet
-> org.apache.calcite.plan.RelTraitSet,java.util.List -> java.util.List <E extends
java.lang.Object>) from class 'org.apache.calcite.rel.core.Join'.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message