You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/06/18 21:10:00 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14592350#comment-14592350 ] 

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

Github user shils commented on a diff in the pull request:

    https://github.com/apache/incubator-groovy/pull/23#discussion_r32766889
  
    --- Diff: src/test/groovy/transform/stc/BugsSTCTest.groovy ---
    @@ -650,4 +650,42 @@ Printer
                 List tmp = (List) m.get("some_key_here")     // <---  actually groovy crashes here!!
             '''
         }
    +
    +    // GROOVY-7416
    +    void testMethodsFromInterfacesOfSuperClassesShouldBeVisible() {
    +        assertScript '''
    +            import groovy.transform.CompileStatic
    +
    +            interface SomeInterface {
    +                void someInterfaceMethod()
    +            }
    +
    +            abstract class AbstractSuperClass implements SomeInterface {}
    +
    +            @CompileStatic
    --- End diff --
    
    Are the CompileStatic annotations here and in the following test necessary? BugsSTCTest extends StaticTypeCheckingTestCase.


> 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
>         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)