[
https://issues.apache.org/jira/browse/GROOVY-10360?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-10360.
------------------------------
> 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)