Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Fix ObjC instancetype inheritance issue. #618

Merged
merged 3 commits into from
Sep 12, 2023
Merged

Fix ObjC instancetype inheritance issue. #618

merged 3 commits into from
Sep 12, 2023

Conversation

liamappelbe
Copy link
Contributor

instancetype is special in ObjC. It's only allowed as the return type of a method, and always takes on the type of the enclosing class, even when that method is being inherited from a base class. So in the generated Dart code we need to copy the method to the subclass, so that we can @override it and return the subclass, rather than just inheriting the base class's version, which returns the base class.

Fixes dart-lang/native#314

Copy link
Contributor

@dcharkes dcharkes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Thanks @liamappelbe ! 🚀

test/native_objc_test/inherited_instancetype_test.dart Outdated Show resolved Hide resolved
@liamappelbe liamappelbe merged commit 1e0fb4c into main Sep 12, 2023
5 of 6 checks passed
@liamappelbe liamappelbe deleted the instancetypefix branch September 12, 2023 04:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Some objects are being classified as NSObject
2 participants