You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/07/04 03:32:04 UTC

[jira] [Resolved] (GROOVY-7416) Problem With CompileStatic And Interface Methods In Abstract Subclass

     [ https://issues.apache.org/jira/browse/GROOVY-7416?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King resolved GROOVY-7416.
-------------------------------
       Resolution: Fixed
         Assignee: Paul King
    Fix Version/s: 2.4.4

proposed PR applied

> Problem With CompileStatic And Interface Methods In Abstract Subclass
> ---------------------------------------------------------------------
>
>                 Key: GROOVY-7416
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7416
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.3
>            Reporter: Jeff Scott Brown
>            Assignee: Paul King
>             Fix For: 2.4.4
>
>         Attachments: abstractcompilestatic.zip, abstractcompilestatic.zip
>
>
> The attached abstractcompilestatic.zip contains the following:
> {code:borderStyle=solid|title=src/main/groovy/demo/SomeInterface.groovy}
> package demo
> interface SomeInterface {
>     void someInterfaceMethod()
> }
> {code}
> {code:borderStyle=solid|title=src/main/groovy/demo/AbstractSuperClass.groovy}
> package demo
> abstract class AbstractSuperClass implements SomeInterface {}
> {code}
> {code:borderStyle=solid|title=src/main/groovy/demo/AbstractSubClass.groovy}
> package demo
> import groovy.transform.CompileStatic
> @CompileStatic
> abstract class AbstractSubClass extends AbstractSuperClass {
>     void someMethod() {
>         someInterfaceMethod()
>     }
> }
> {code}
> The code will not compile.
> {noformat}
>  $ ./gradlew clean compileGroovy
> :clean
> :compileJava UP-TO-DATE
> :compileGroovy
> startup failed:
> /Users/jeff/abstractcompilestatic/src/main/groovy/demo/AbstractSubClass.groovy: 9: [Static type checking] - Cannot find matching method demo.AbstractSubClass#someInterfaceMethod(). Please check if the declared type is right and if the method exists.
>  @ line 9, column 9.
>            someInterfaceMethod()
>            ^
> 1 error
> :compileGroovy FAILED
> FAILURE: Build failed with an exception.
> * What went wrong:
> Execution failed for task ':compileGroovy'.
> > Compilation failed; see the compiler error output for details.
> * Try:
> Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
> BUILD FAILED
> Total time: 4.045 secs
> {noformat}
> If the AbstractSubClass is modified to implement the interface as shown below the code will compile:
> {code:borderStyle=solid|title=src/main/groovy/demo/AbstractSubClass.groovy}
> package demo
> import groovy.transform.CompileStatic
> @CompileStatic
> abstract class AbstractSubClass extends AbstractSuperClass implements SomeInterface {
>     void someMethod() {
>         someInterfaceMethod()
>     }
> }
> {code}



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