eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[4.35+] Refactor ConditionalExpression and SwitchExpression by making them implement INumericChoiceContext
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
JLS 5.6 classifies `SwitchExpression` and `ConditionalExpression` as constructs in numeric choice context (when all result expressions are numeric) The computation of result type, their polyness or not all are all similarly defined. Essentially a switch is multi-way-conditional.
As such there is enormous room for code sharing by hoisting contract and default behavior to a new interface type say `INumericChoiceContext` that both switch expressions and ternary operators implement.
Comparing `org.eclipse.jdt.internal.compiler.ast.SwitchExpression.resolveType(BlockScope)` and `org.eclipse.jdt.internal.compiler.ast.ConditionalExpression.resolveType(BlockScope)` it is possible for the latter to be as minimal as the former.
Contributor guide
Assessment
This issue has not been assessed yet.