jdaugherty commented on PR #3081: URL: https://github.com/apache/groovy/pull/3081#issuecomment-6511435399
Good question. The gate asymmetry predates this PR: 282ba5cd6d (GROOVY-10922) made the getter always synthesize when the declaring class has no getter, and the setter only when every candidate is abstract. This PR changes position only. The getter is gated differently rather than not at all. `getGetterMethod(name)` on the declaring class searches that class, its superclasses and (GROOVY-11381) interface default getters, so a concrete getter in any of those suppresses the synthetic. The concrete candidates that can still share the list are a subclass override, which `removeCovariantsAndInterfaceEquivalents` drops through `isDerivedFrom` in either pair order, and an enclosing-class method, which the receiver-distance phase decides regardless of order. Position only affects the class-vs-interface rule, which drops the interface method solely when it comes second. When neither is dropped, the receiver distance ranks an interface implemented by the superclass at 1 and the superclass itself at 4, so the interface won whenever the receiver was narrowed to a subclass (`Impl` here); with the receiver exactly `Base`, master already chose the accessor. I checked with this ordering and with master's: a concrete superclass accessor and a concrete covariant subclass override (`Object` property, `String` getter) select the concrete method in both orderings, and the subclass case keeps the `()Ljava/lang/String;` descriptor. Both are now tests in `Groovy12552`, and the comment at the getter `add(0, …)` says why no abstract-only gate is needed there. Interface default accessors are a separate, pre-existing gap: neither synthetic is created, so the together-compile uses `invokeinterface` and the incremental one `invokevirtual`. I can file that separately. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
