[
https://issues.apache.org/jira/browse/GROOVY-12522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139864#comment-18139864
]
ASF GitHub Bot commented on GROOVY-12522:
-----------------------------------------
codeconsole commented on PR #3048:
URL: https://github.com/apache/groovy/pull/3048#issuecomment-6694086592
@daniellansun could you take another look? The implements-only case you
asked for is covered: `super.first()` in a class that implements `Iterable`, or
delegates `List` with `@Delegate`, reaches the extension method (39b195ca9a,
`testSuperDotExtensionMethodOfAnInterfaceOfTheClass`). The branch still merges
cleanly, and that test and `groovy.ThisAndSuperTest` pass on a local merge with
current master.
> super.name() and super.name miss an extension method that the class overrides
> -----------------------------------------------------------------------------
>
> Key: GROOVY-12522
> URL: https://issues.apache.org/jira/browse/GROOVY-12522
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> When a class declares its own version of an extension method of its
> superclass, {{super.name()}} and {{super.name}} in dynamic Groovy and under
> {{@TypeChecked}} do not find the superclass's extension method:
> {code:groovy}
> class Numbers extends ArrayList<Integer> {
> Numbers() { super([1, 2, 3]) }
> Integer first() { -1 }
> def test() { super.first() }
> }
> class Bean {
> Map getProperties() { [:] }
> def test() { super.properties.containsKey('class') }
> }
> class Text extends File {
> Text(String path) { super(path) }
> String getText() { 'own' }
> def test() { [super.getText(), super.text] }
> }
> assert new Numbers().test() == 1 // fails: MissingMethodException: No
> signature of method: first for class: java.util.ArrayList
> assert new Bean().test() // fails: MissingPropertyException: No such
> property: properties for class: Bean
> def file = File.createTempFile('text', '.txt')
> file.text = 'content'
> assert new Text(file.path).test() == ['content', 'content'] // fails:
> NullPointerException: charsetName
> {code}
> {{super.getText()}} calls {{getText(File, String charset)}} with a null
> charset, the only {{getText}} left for {{super}}. Without the class's own
> method, all three work. Under {{@CompileStatic}} these calls work, but
> {{super.text += 'x'}} compiles to a dynamic property access and fails the
> same way. Seen in 4.0.33, 5.0.8, 6.0.0 and master.
> For {{super}}, a method the class declares is replaced by the MOP method
> {{super$2$name}} of the superclass method it overrides, or dropped when there
> is none. An extension method has no MOP method, so the class's method is
> dropped, and the extension method it replaced in the method index is not
> restored.
> Expected: {{super.name()}} and {{super.name}} call the superclass's extension
> method, as they do when the class does not declare the method.
> PR: https://github.com/apache/groovy/pull/3048
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)