paulk-asert opened a new pull request, #3119: URL: https://github.com/apache/groovy/pull/3119
Reworks GROOVY-12315 (flow typing of final `def` fields) after review found that the merged change applied the field's type to reads through its property getter, which a subclass may override, and that reads from other classes depended on the order of the classes in the source. Four commits: 1. **Revert GROOVY-12315 pending a narrower design** — reverts the three merged commits so the new design is a diff of its own. 2. **Read a final `def` field with the type of its value within its class** — the field's type is still the type of its initializer and of the plain assignments in its constructors and initializer blocks, as for a local variable, but it is used only where the field itself is read: in the declaring class's own method, constructor and initializer bodies, and from a closure or lambda for a private field or a static property. A read through the getter keeps `Object` (closures and lambdas reading a property, inner classes, subclasses, other classes). A value of no one type blocks the flow type rather than pinning a synthesized bound, so constructors assigning unrelated types cannot make an overload ambiguous. About 100 lines fewer than before: the write scan is gone (every write outside initialization is already a compile error), as are the cross-class readiness flags. 3. **Read a final `def` field with its flow type from a closure of a final class** — a closure or lambda in a `final` class that declares no getter of its own reads the generated getter, which nothing can override, so it gets the flow type too. 4. Docs for above Tests: `bugs.Groovy12315` (48 tests) covers the reads that use the flow type, those that don't, and the soundness cases, including a subclass overriding the getter. The `groovy.transform.*`, `classgen.asm.sc.*`, `gls.*`, `bugs.*` and trait suites pass. A COMPATIBILITY entry describes the overload-selection and `instanceof` effects under `@CompileStatic`. This tries to be less ambitious than the earlier work. 2 is the minimal step forward. 2 plus 3 gives more - just a little harder to explain. For `GROOVY_6_0_X` the original change has been reverted; I envisage this is for master only. -- 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]
