[Tests] Cover @derivative module selector in ModuleSelectorTests#3375
Open
devdattatalele wants to merge 1 commit into
Open
[Tests] Cover @derivative module selector in ModuleSelectorTests#3375devdattatalele wants to merge 1 commit into
devdattatalele wants to merge 1 commit into
Conversation
Add a substructure assertion inside testModuleSelectorCorrectCode for @Derivative(of: Module::name). The argument list flows through parseQualifiedDeclarationName -> parseDeclReferenceExpr and therefore already accepts module selectors; the new test locks that behavior in for the simple decl-reference form. The existing @Derivative test in testModuleSelectorAttrs covers the complex qualified form (@Derivative with member access + wrt clause). This new test covers the simpler decl-reference form in testModuleSelectorCorrectCode alongside the neighbouring @_implements and @_dynamicReplacement module-selector coverage. Drop the pre-existing FIXME. The @_differentiable(jvp:vjp:) legacy argument form referenced by that FIXME has been removed from the language, and the underscore-prefixed @_derivative spelling is no longer parsed as a derivative-registration attribute (only the modern @Derivative spelling is recognised - see DeclarationAttributeWithSpecialSyntax in Sources/SwiftParser/Attributes.swift).
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.
Summary
Adds a substructure assertion inside
testModuleSelectorCorrectCodefor the modern autodiff registration attribute with a module selector in itsof:argument:The attribute argument list flows through
parseQualifiedDeclarationName→parseDeclReferenceExpr, so module selectors are already supported by the parser. The new test locks that behaviour in for the simple decl-reference form, complementing the existing test intestModuleSelectorAttrs(line 1754 in the pre-patch file) which covers the complexmember.accessform with awrt:clause.Context
Addresses the pre-existing FIXME in
Tests/SwiftParserTest/translated/ModuleSelectorTests.swift:Both attribute names in the FIXME use their legacy underscore-prefixed spellings. Neither is recognised by the current parser as the special-syntax attribute it refers to:
@_derivative— the.derivativekeyword text is"derivative"(no underscore) inSources/SwiftSyntax/generated/Keyword.swift.DeclarationAttributeWithSpecialSyntaxinSources/SwiftParser/Attributes.swiftmatches on this keyword, so source@_derivativeis not recognised as a derivative-registration attribute. The modern spelling is@derivative.@_differentiable(jvp:vjp:)— thejvp:/vjp:argument labels have been removed fromparseDifferentiableAttributeArguments; the modern differentiable attribute usesKindSpecifier,wrt:, andwhereclauses instead.The addressable intent of the FIXME — module-selector coverage for a derivative registration attribute inside
testModuleSelectorCorrectCode— is satisfied here with the modern@derivativespelling.The adjacent FIXME about
@convention(witness_method:)is a type-attribute concern parsed by different code and is intentionally out of scope.Test plan
swift test --test-product SwiftParserTestspasses.swift format -ipr .produces no diff.testModuleSelectorCorrectCode()alongside the existing@_implementsand@_dynamicReplacementmodule-selector coverage. Same substructure pattern as neighbouring tests.@derivativetest intestModuleSelectorAttrs(that test covers the complexSwift::Foo.Swift::Bar.Swift::baz()qualified form withwrt: quux; this test covers the simpleModule::namedecl-reference form).Files changed
Tests/SwiftParserTest/translated/ModuleSelectorTests.swift: +30 / -2 lines