Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13688] Require @derivative functions to have same access level as original declaration #54433

Closed
marcrasi mannequin opened this issue Jan 8, 2020 · 1 comment
Closed
Assignees

Comments

@marcrasi
Copy link
Mannequin

marcrasi mannequin commented Jan 8, 2020

Previous ID SR-13688
Radar None
Original Reporter @marcrasi
Type Sub-task
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s
Labels Sub-task
Assignee @dan-zheng
Priority Medium

md5: 0dbde34bbd94cb985766a69c54a30d86

Parent-Task:

  • SR-13659 Retroactive derivative registration

blocks:

  • TF-1160 Linker error for @usableFromInline derivative but non-@usableFromInline original function

relates to:

Issue Description:

Require @derivative functions to have the same access level as their referenced original declaration.
One exception: @derivative functions for a public function can be either public or internal and @usableFromInline.

Same rules should apply to @transpose attribute.


Anonymous func declarations (SR-12003) enable public @derivative functions without publicly exposing the derivative function:

public func bar(_ x: Float) -> Float { x }

// Publicly registered derivative. Derivative function itself is not exposed, however.
@derivative(of: bar)
public func _(_ x: Float) -> (value: Float, differential: (Float) -> Float) {
  (x, { dx in dx })
}

// Publicly registered transpose. Transpose function itself is not exposed, however.
@transpose(of: bar)
public func _(_ v: Float) -> Float { v }
@dan-zheng
Copy link
Collaborator

Done in #31527

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant