Skip to content

[5.3] Mark non-foreign entry points of @objc dynamic methods in generic classes dynamically_replaceable #32300

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

Conversation

aschwaighofer
Copy link
Contributor

  • Description:
class Generic<T> {
  @objc dynamic func method() {}
}

extension Generic {
  @_dynamicReplacement(for:method())
  func replacement() {}
}

The standard mechanism of using Objective-C categories for dynamically
replacing @objc methods in generic classes does not work.

Instead we mark the native entry point as replaceable.

Because this affects all @objc methods in generic classes (whether there
is a replacement or not) by making the native entry point
[dynamically_replaceable] (regardless of optimization mode) we guard this by
the -enable-implicit-dynamic flag because we are late in the release cycle.

  • Scope: Before this patch @_dynamicReplacement(for:) was not allowed on
    objective c methods in generic classes.

  • Risk: Medium. Should only affect entry points that did not work before.

  • Reviewed by: Slava Pestov

  • Testing: Regression test added

rdar://63679357

…eric classes `dynamically_replaceable`

```

* Description:

class Generic<T> {
  @objc dynamic func method() {}
}

extension Generic {
  @_dynamicReplacement(for:method())
  func replacement() {}
}
```

The standard mechanism of using Objective-C categories for dynamically
replacing @objc methods in generic classes does not work.

Instead we mark the native entry point as replaceable.

Because this affects all @objc methods in generic classes (whether there
is a replacement or not) by making the native entry point
`[dynamically_replaceable]` (regardless of optimization mode) we guard this by
the -enable-implicit-dynamic flag because we are late in the release cycle.

* Scope: Before this patch @_dynamicReplacement(for:) was not allowed on
objective c methods in generic classes.

* Risk: Medium. Should only affect entry points that did not work before.

* Reviewed by: Slava Pestov

* Testing: Regression test added

rdar://63679357
@aschwaighofer aschwaighofer requested a review from a team as a code owner June 10, 2020 18:44
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer aschwaighofer merged commit 3d4a9cf into swiftlang:release/5.3 Jun 11, 2020
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants