[ https://issues.apache.org/jira/browse/GROOVY-11250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17797938#comment-17797938 ]
Eric Milles commented on GROOVY-11250: -------------------------------------- For this code: {code:groovy} def oneToOne = new OneToOne<Attribute>('foo') {} def oneToMany = new OneToMany<Attribute>('bar') {} for (association in [oneToOne, oneToMany]) { if (association instanceof ToOne) { def propertyName = association.name println "to-one -> $propertyName" } else if (association instanceof OneToMany || association instanceof ManyToMany) { def association_name = association.getName() // <-- this is a workaround // next line compiles in 3.0.19 but not in 3.0.20-SNAPSHOT def propertyName = association.name println "to-many -> $propertyName" } } {code} The type-checker works out that "association" of "association.getName()" or "association.name" (in the else block) has types: # {{Association<Attribute>}} # {{ToMany<Object>}} // the raw types in the instanceof result in the erasure type for T # {{<UnionType:bugs.OneToMany+bugs.ManyToMany>}} Both the method invocation and property access work out that the method {{AbstractPersistentProperty#getName()}} satisfies. The method call expression goes through a direct target path during classgen. The property expression takes a longer route where the CallSiteWriter looks again for the method. The difference in node meta data for "association" between Groovy 3.0.19 and 3.0.20-SNAPSHOT is the reason for the compiler error. > Compilation fails when accessing getter with shortcut notation on Java class > ---------------------------------------------------------------------------- > > Key: GROOVY-11250 > URL: https://issues.apache.org/jira/browse/GROOVY-11250 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 3.0.20 > Reporter: Mattias Reichel > Assignee: Eric Milles > Priority: Major > > Example project that demonstrates the issue: > [https://github.com/matrei/bug-groovy-java-getter] > Workaround: Use long form o.getName() instead of o.name > -- This message was sent by Atlassian Jira (v8.20.10#820010)