paulk-asert commented on PR #2933: URL: https://github.com/apache/groovy/pull/2933#issuecomment-6449293792
@blackdrag re your "Architectural concerns" review, see if https://github.com/apache/groovy/pull/3055 is heading in the direction you are after. > What it is > > - `MatchPattern` (`org.apache.groovy.ast.pattern`): a sealed interface whose records cover type, record, list, map, binding (`var x`), wildcard (`_`), constant and rest patterns. "Can this pattern fail?" and "what does it cover?" are now answered once, here, instead of half in parser flags and half in STC. > - `PatternExpression` (`org.codehaus.groovy.ast.expr`): the node that is the case label, or the instanceof test. It keeps the pattern from parsing through to codegen. Its transformExpression rebuilds the whole node, so a transformer can't drop the pattern. `GroovyCodeVisitor` gets a default `visitPatternExpression`, as `visitSwitchExpression` did in 6.0. > - PatternLowering: one named pass that runs first in semantic analysis. All lowering is gone from AstBuilder (−526 / +120 lines). > - Cleanup: > - The type checker reads the model instead of 27 metadata lookups. > - The 11 `SwitchPatternUtils` key constants are deleted. > - The two `copyNodeMetaData` patches in `ResolveVisitor/StaticImportVisitor` are reverted, and var-component typing under `@CompileStatic` still passes. That is Jochen's point 1, shown concretely. > > Overall: existing files +295 / −701, plus about 830 lines across the 3 new files. > > Proven by the new tests > > `PatternExpressionTest` (5 tests) builds a pattern switch and an instanceof record pattern from the model alone, in a CONVERSION-phase customizer, and runs them dynamically and under `@CompileStatic`. That's Jochen's point 2. It also checks that a parsed label keeps its pattern before and after lowering. > > Not done yet: > - `SecureASTCustomizer` and the console AST browser only see the lowered code. > - Plain `o instanceof T t` isn't migrated to the node. > - The new public `@Incubating` surface still needs listing for japicmp. If that looks like the right direction, I'll retire this PR and do the completion work on that one. -- 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]
