You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/11/12 14:54:00 UTC

[jira] [Resolved] (GROOVY-10360) STC ignores declared type of variable

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

Eric Milles resolved GROOVY-10360.
----------------------------------
    Resolution: Information Provided

> STC ignores declared type of variable
> -------------------------------------
>
>                 Key: GROOVY-10360
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10360
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Priority: Major
>
> I don't know if this is a bug or an expected behaviour, but in the following example, groovyc ignores the declared type of variable `x`.
> {code:java}
> class A {
>   void m() {}
> }
> class Test {
>   public static void main(String[] args) {
>     final Object x = foo();
>     x.m(); // should report an error. method `m` is not found in class Object.
>   }
>   public static A foo() {
>     return new A();
>   }
> }
> {code}
> h3. Actual behaviour
> groovyc compiles this program
> h3. Expected behaviour
> groovyc should reject this program with an error of the form
> {code}
> Cannot find method Object#m()
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)