Skip to content

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