Repository navigation
fix: preserve switch diagnostic type casing - W-24796367 - #836
peternhale wants to merge 2 commits into
Conversation
3d8b6b5 to
a30b11a
Compare
E2E Test Results SummaryRun: 2227 Test Results
Passing Rate by File
ArtifactsView detailed test reports in the Artifacts section. Some tests failed |
madhur310
left a comment
There was a problem hiding this comment.
Nice fix — the displayType split cleanly separates the case-insensitive comparison path from diagnostic rendering, and the new exact-message tests lock in the expected output.
One minor gap worth a follow-up: canonicalization is inconsistent depending on how the type was resolved.
- Literal when-values always go through
literalTypeDisplay(SwitchStatementValidator.ts:315), so123renders asIntegerregardless of source casing. - Identifier/variable-resolved types (
resolveIdentifierType,SwitchStatementValidator.ts:293-312) and thesemanticTypebranch ofswitchTypeDisplay(SwitchStatementValidator.ts:319-324) just echosymbol.type.originalTypeString/semanticType.originalTypeStringverbatim.
Since Apex primitive keywords are case-insensitive, a declaration like public static final integer MY_CONST = 1; (lowercase integer) used in a when/switch expression will still render as "integer" in the diagnostic rather than "Integer" — which seems to contradict the PR description's second bullet about canonicalizing intrinsic types for display. Not a functional bug (comparisons are unaffected), just an inconsistency in the cosmetic casing fix. No test currently exercises a lowercase-declared primitive, so it's easy to miss.
Approving since this is a real improvement and the gap is narrow/cosmetic — happy to see it addressed in a follow-up.
7af589f to
ba672dd
Compare
43762aa to
749a3c1
Compare
What does this PR do?
Preserves Apex/Jorje type-name casing in switch diagnostics while retaining normalized type names for semantic comparisons.
Integer,String, andIdfor diagnostic display.whenexpression types.What issues does this PR fix or reference?
@W-24796367@
Test Plan
pnpm exec vitest run packages/apex-parser-ast/test/semantics/validation/validators/SwitchStatementValidator.test.ts --reporter=defaultpnpm --filter @salesforce/apex-lsp-parser-ast run lintpnpm --filter @salesforce/apex-lsp-parser-ast run test