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

The selector type is private #1861

Closed
stuartmorgan-g opened this issue Jan 3, 2025 · 0 comments · Fixed by #1897
Closed

The selector type is private #1861

stuartmorgan-g opened this issue Jan 3, 2025 · 0 comments · Fixed by #1897

Comments

@stuartmorgan-g
Copy link

stuartmorgan-g commented Jan 3, 2025

As a follow-up to the discussion in #1580 and the changes there: getting a selector is now public, but the type it returns is not; as a client of objective_c, the type returned by toSelector() is Pointer<_ObjCSelector>. This has some very problematic properties, including:

  • I cannot declare a variable that stores a selector that is fully typed, which in turn means I cannot declare such a variable in flutter/packages (or flutter/flutter) without an // ignore directive.
  • I cannot mock any generated objects in unit tests without a bunch of extra work due to errors like:
     Invalid @GenerateMocks annotation: Mockito cannot generate a valid mock class which implements 'NSBundle' for the following reasons:
         The method 'NSObject.doesNotRecognizeSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.forwardingTargetForSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.methodForSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.methodSignatureForSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.performSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.performSelector_withObject_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.performSelector_withObject_withObject_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
         The method 'NSObject.respondsToSelector_' features a private type argument, and cannot be stubbed. Try generating this mock with a MockSpec with 'unsupportedMembers' or a dummy generator (see https://pub.dev/documentation/mockito/latest/annotations/MockSpec-class.html).
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants