Skip to content

Commit 87dcf25

Browse files
committed
Remove NSObject special-casing
The cases where this triggered was strictly incorrect, and not really necessary anyway.
1 parent 723c865 commit 87dcf25

5 files changed

Lines changed: 5 additions & 8 deletions

File tree

crates/header-translator/src/id.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,6 @@ impl ItemIdentifier {
288288
self.map_name(Some)
289289
}
290290

291-
pub fn is_nsobject(&self) -> bool {
292-
self.library_name() == "objc2"
293-
&& (self.name == "NSObject" || self.name == "NSObjectProtocol")
294-
}
295-
296291
pub fn is_nserror(&self) -> bool {
297292
self.library_name() == "Foundation" && self.name == "NSError"
298293
}

crates/header-translator/src/rust_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,6 @@ impl Ty {
14161416
Self::GenericParam { name } => write!(f, "{name}"),
14171417
Self::AnyObject { protocols } => match &**protocols {
14181418
[] => write!(f, "AnyObject"),
1419-
[decl] if decl.id.is_nsobject() => write!(f, "NSObject"),
14201419
[decl] => write!(f, "ProtocolObject<dyn {}>", decl.id.path()),
14211420
// TODO: Handle this better
14221421
[first, rest @ ..] => {

crates/header-translator/src/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ impl Stmt {
18541854
// The object inherits from `NSObject` or `NSProxy` no
18551855
// matter what the generic type is, so this must be
18561856
// safe.
1857-
(_, _) if protocol.is_nsobject() => ("?Sized", None),
1857+
("Foundation", "NSObjectProtocol") => ("?Sized", None),
18581858
// Encoding and decoding requires that the inner types
18591859
// are codable as well.
18601860
("Foundation", "NSCoding") => ("?Sized + NSCoding", None),

crates/objc2/src/topics/about_generated/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
7676
of `"LAContext"`.
7777
* **BREAKING**: Cfg-gated `HKAudiogramSensitivityPoint` behind
7878
`"HKAudiogramSensitivityPoint"` instead of `"HKAudiogramSample"`.
79+
* **BREAKING**: No longer special-case `NSObjectProtocol` objects. Certain
80+
methods that previously used `&NSObject` for convenience now use the more
81+
correct `&ProtocolObject<dyn NSObjectProtocol>`.
7982

8083
### Deprecated
8184
* Moved `MainThreadMarker` from `objc2-foundation` to `objc2`.

0 commit comments

Comments
 (0)