Improve @Variant diagnostics, name handling, and default-argument support#1
Merged
Conversation
…port - Treat explicit empty name: as a verbatim value instead of silently falling back to the member name. - Diagnose non-constant name: (interpolated/computed) instead of silently ignoring it and using the member name. - Allow static func parameters with default values to be omitted from @variant (pass between required and total parameter count). - Warn on duplicate explicit names across members/cases. - Point argument-count and stored-property diagnostics at the offending @variant attribute rather than the whole declaration. - Offer a fix-it that inserts a name: placeholder for the missing-name-with-multiple-@variant warning. - Add runtime tests that exercise the generated code end-to-end, plus tests for the new diagnostics and behaviors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XYWfJmDzCJrBaESbryzg4L
A private type's generated allVariants was emitted as `private`, which is not visible from the separate conformance extension, so the protocol requirement could not be satisfied (the compiler asks for `fileprivate`). Map both `private` and `fileprivate` types to `fileprivate` members. This was a latent bug surfaced by the new end-to-end runtime tests, which use a private type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XYWfJmDzCJrBaESbryzg4L
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
falling back to the member name.
silently ignoring it and using the member name.
@variant (pass between required and total parameter count).
@variant attribute rather than the whole declaration.
missing-name-with-multiple-@variant warning.
tests for the new diagnostics and behaviors.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01XYWfJmDzCJrBaESbryzg4L