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 2024/06/03 19:51:00 UTC

[jira] [Updated] (GROOVY-11393) STC: error for non-static member of class delegate

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

Eric Milles updated GROOVY-11393:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
class Foo {
  static getBar() { 'bar' }
  Object getBaz() { 'baz' }
}

@groovy.transform.TypeChecked
void test() {
  def foo = Foo
  foo.with {
    println bar
    println baz
    println getBar()
    println getBaz()
  }
}

test()
{code}

This script prints "bar" and then throws a {{MissingPropertyException}} or {{ClassCastException}} (static compilation).  The type checker does not warn of non-static member access for a {{Class}} delegate.

GROOVY-10820

  was:
Consider the following:
{code:groovy}
class Foo {
  static getBar() { 'bar' }
  Object getBaz() { 'baz' }
}

@groovy.transform.TypeChecked
void test() {
  def foo = Foo
  foo.with {
    println bar
    println baz
    println getBar()
    println getBaz()
  }
}

test()
{code}

This script prints "bar" and then throws a {{MissingPropertyException}} or {{ClassCastException}} (static compilation).  The type checker does not warn of non-static member access for a {{Class}} delegate.


> STC: error for non-static member of class delegate
> --------------------------------------------------
>
>                 Key: GROOVY-11393
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11393
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 3.0.21, 5.0.0-alpha-8, 4.0.21
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class Foo {
>   static getBar() { 'bar' }
>   Object getBaz() { 'baz' }
> }
> @groovy.transform.TypeChecked
> void test() {
>   def foo = Foo
>   foo.with {
>     println bar
>     println baz
>     println getBar()
>     println getBaz()
>   }
> }
> test()
> {code}
> This script prints "bar" and then throws a {{MissingPropertyException}} or {{ClassCastException}} (static compilation).  The type checker does not warn of non-static member access for a {{Class}} delegate.
> GROOVY-10820



--
This message was sent by Atlassian Jira
(v8.20.10#820010)