Skip to content

6.0: [TypeLowering] Return pseudogeneric @autoreleasing. #74131

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

nate-chandler
Copy link
Contributor

Explanation: Fix a leak in certain Swift extensions of pseudogeneric ObjC types.

Given a pseudogeneric Objective-C type

@interface PG<T>
@end

it's permitted to write an extension in Swift which returns the pseudogeneric parameter

extension PG {
  func get() -> T {...}
}

which can be called from ObjC. To match Objective-C conventions, these methods should return values autoreleased.

Previously, these methods returned values unowned. The result was a memory leak and a corresponding SIL verification error.

Here, this is fixed by using the @autoreleased convention in such cases.
Scope: Affects extensions of pseudogeneric ObjC types.
Issue: rdar://64375208
Original PR: #74072
Risk: Low.
Testing: Enabled SIL verification in existing test.
Reviewer: Andrew Trick ( @atrick )

Previously, when a pseudogeneric function returned a type parameter, it
was unowned.  That resulted in invalid OSSA out of SILGen.  Here, this
is fixed to use the @autoreleasing convention.

rdar://64375208
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler enabled auto-merge June 5, 2024 00:41
@nate-chandler nate-chandler merged commit a632ee7 into swiftlang:release/6.0 Jun 5, 2024
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar64375208 branch June 5, 2024 14:06
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.

2 participants