getPatternCaseKey returns the case key for a pattern. Constructor patterns return their full type name. Wildcard and variable patterns return "default".
(pattern ast.Pattern)
| 231 | // Constructor patterns return their full type name. |
| 232 | // Wildcard and variable patterns return "default". |
| 233 | func (g *MatchCodeGen) getPatternCaseKey(pattern ast.Pattern) string { |
| 234 | switch p := pattern.(type) { |
| 235 | case *ast.ConstructorPattern: |
| 236 | return g.constructorToTypeName(p.Name) |
| 237 | case *ast.LiteralPattern: |
| 238 | return "literal:" + p.Value |
| 239 | case *ast.WildcardPattern, *ast.VariablePattern: |
| 240 | return "default" |
| 241 | default: |
| 242 | return "default" |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // generateGroupedCase generates a single case clause for a group of arms. |
| 247 | // If the group has multiple arms, generates if/else chain for guards. |
no test coverage detected