Skip to content

[c++-interop] Teach APINotes to handle ObjCContainer items while in C++-Interop #4118

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

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

plotfi
Copy link

@plotfi plotfi commented Mar 24, 2022

In a previous commit I taught APINotes to treat extern-c context as a
toplevel file context, but this only makes sense when we are handling
the decls handled in the block like VarDecls, FunctionDecls,
ObjCInterfaceDecls, etc.

But when the decl being handled for APINote is an ObjCMethod inside of a
ObjCContainer then it is important to allow the subsequent code in the
Sema::ProcessAPINotes function to handle things.

This can be excercised by the following APINote:

---
Name: SomeModule
Classes:
- Name: NSSomeClass
  SwiftName: SomeClass
  Methods:
  - Selector: 'didMoveToParentViewController:'
    SwiftName: didMove(toParent:)
    MethodKind: Instance
    

@plotfi
Copy link
Author

plotfi commented Mar 24, 2022

@hyp @zoecarver @bulbazord @drodriguez

Test is coming, but this should fix the ObjCMethod case. I will have a PR for the swift repo as well soon. Basically this covers:

// test.apinote:

---
Name: SomeModule
Classes:
- Name: NSSomeClass
  SwiftName: SomeClass
  Methods:
  - Selector: 'didMoveToParentViewController:'
    SwiftName: didMove(toParent:)
    MethodKind: Instance

// test.h
@interface NSSomeClass
  -(instancetype)init;
@end

@interface NSSomeClass (SomeCategory)
- (void)didMoveToParentViewController:(NSSomeClass *)parent;
@end

@drodriguez
Copy link

I did a quick check and it seems to remove 50 failing tests from the full test suite with C++ interop enabled (down to 452 from 502). Seems promising.

plotfi added a commit to plotfi/swift that referenced this pull request Mar 24, 2022
This is swift test to go with swiftlang/llvm-project#4118

The test is verifying that a ObjCMethod that is annotated by an APINote
is in fact getting the APINote applied. These types of APINotes are
heavily used by UIKit for instance in didMoveToParentViewController in
UIViewController.
@hyp
Copy link

hyp commented Mar 24, 2022

@swift-ci please test

1 similar comment
@zoecarver
Copy link

@swift-ci please test

@plotfi
Copy link
Author

plotfi commented Mar 31, 2022

With #4148 already landed, this commit is just an added test case for ObjCMethod.

@plotfi plotfi force-pushed the stable/20211026 branch 2 times, most recently from 15dbf5c to 8cc2354 Compare March 31, 2022 19:38
…erop

In a previous commit I taught APINotes to treat extern-c context as a
toplevel file context, but this only makes sense when we are handling
the decls handled in the block like VarDecls, FunctionDecls,
ObjCInterfaceDecls, etc.

But when the decl being handled for APINote is an ObjCMethod inside of a
ObjCContainer then it is important to allow the subsequent code in the
Sema::ProcessAPINotes function to handle things.

This can be excercised by the following APINote:

```
---
Name: SomeModule
Classes:
- Name: NSSomeClass
  SwiftName: SomeClass
  Methods:
  - Selector: 'didMoveToParentViewController:'
    SwiftName: didMove(toParent:)
    MethodKind: Instance
```

This commit is now just a test case due to another commit that has
already landed.
@hyp
Copy link

hyp commented Apr 4, 2022

@swift-ci please test

@hyp hyp merged commit ca540bf into swiftlang:stable/20211026 Apr 6, 2022
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

Successfully merging this pull request may close these issues.

4 participants