[
https://issues.apache.org/jira/browse/GROOVY-11820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Björn Kautler updated GROOVY-11820:
-----------------------------------
Description:
If you [execute
this|https://groovyconsole.dev/?g=groovy_4_0&codez=eNqlj8EOgjAMhu97it4Yl72BidGEqwd9gQnbAhmMbNWEGN7dboIQ9GBiL8u-5v_a1m3vPEIj71JY2RnhlbaqRFHUylaM7Y8SlXF-4AnkrLQyBCicgwcDqjP6ujNgFF6GXvF8wrEyHSOAxEF718ZUlrojG1fm07WhibP6IP0PapcyKzfFFjerlIbX9N2kEekb6PEBec56gmg7nrCIni17z10aObsFxemMeZdvlk--Mo0bF639h-sJdk-N3A]:
{code:groovy}import java.lang.reflect.Field
@Category(Field)
class Foo {
String getType() {
'field type from Foo'
}
}
@Category(Object)
class Bar {
String getType() {
'object type from Bar'
}
}
def field = String.fields.first()
println(field.type)
println(field.getType())
println()
use(Foo) {
println(field.type)
println(field.getType())
}
println()
use(Bar) {
println(field.type)
println(field.getType())
}
{code}
The result is
{code:none}interface java.util.Comparator
interface java.util.Comparator
field type from Foo
field type from Foo
object type from Bar
interface java.util.Comparator{code}
Do I need to say any more? :-)
was:
If you [execute
this|https://groovyconsole.dev/?g=groovy_4_0&codez=eNq1jzEOwjAMRfecwuqULDkDAqkrA1wglDRqFZrKMUgV6t1xAqUVS7vgJdLP_-_bza0PSNCah9HedE6jrb2tSJeN9VchdgdD1gUcZBaUqLyJEcoQ4CmA50TYdA6cpfPQW6k-cpqiThEg1qHGcEupIv-OYlyQj5eWGyf03uAGdMiZBZtjM1v0nCTfyTdC50UiPxhJKp1SasXzbZ2NStyjlXzEtMmWlnXfomn86eKj_tj1AtnOpKU]:
{code:groovy}
import java.lang.reflect.Field
@Category(Field)
class Foo {
String getType() {
"field type from Foo"
}
}
@Category(Object)
class Bar {
String getType() {
"object type from Bar"
}
}
println(String.fields.first().type)
println(String.fields.first().getType())
println()
use(Foo) {
println(String.fields.first().type)
println(String.fields.first().getType())
}
println()
use(Bar) {
println(String.fields.first().type)
println(String.fields.first().getType())
} {code}
The result is
{code:none}interface java.util.Comparator
interface java.util.Comparator
field type from Foo
field type from Foo
object type from Bar
interface java.util.Comparator{code}
Do I need to say any more? :-)
> Overwriting a getter method in a supertype via category results in
> inconsistent property / getter behavior
> ----------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-11820
> URL: https://issues.apache.org/jira/browse/GROOVY-11820
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.23, 3.0.25, 4.0.29, 5.0.3
> Reporter: Björn Kautler
> Priority: Major
>
> If you [execute
> this|https://groovyconsole.dev/?g=groovy_4_0&codez=eNqlj8EOgjAMhu97it4Yl72BidGEqwd9gQnbAhmMbNWEGN7dboIQ9GBiL8u-5v_a1m3vPEIj71JY2RnhlbaqRFHUylaM7Y8SlXF-4AnkrLQyBCicgwcDqjP6ujNgFF6GXvF8wrEyHSOAxEF718ZUlrojG1fm07WhibP6IP0PapcyKzfFFjerlIbX9N2kEekb6PEBec56gmg7nrCIni17z10aObsFxemMeZdvlk--Mo0bF639h-sJdk-N3A]:
> {code:groovy}import java.lang.reflect.Field
> @Category(Field)
> class Foo {
> String getType() {
> 'field type from Foo'
> }
> }
> @Category(Object)
> class Bar {
> String getType() {
> 'object type from Bar'
> }
> }
> def field = String.fields.first()
> println(field.type)
> println(field.getType())
> println()
> use(Foo) {
> println(field.type)
> println(field.getType())
> }
> println()
> use(Bar) {
> println(field.type)
> println(field.getType())
> }
> {code}
> The result is
> {code:none}interface java.util.Comparator
> interface java.util.Comparator
> field type from Foo
> field type from Foo
> object type from Bar
> interface java.util.Comparator{code}
>
> Do I need to say any more? :-)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)