dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
157 stars 44 forks source link

ObjC: Class hierarchy should be duplicated in generated Dart code. #266

Open brianquinlan opened 2 years ago

brianquinlan commented 2 years ago

Objective-C interfaces are converted to Dart classes that extend _ObjCWrapper e.g.

class NSString extends _ObjCWrapper {

Instead, they should extend their actual superclass e.g.

class NSString extends NSObject {

Otherwise NSString cannot be passed when NSObject is expected.

FYI, castFrom can be used as a workaround.

liamappelbe commented 2 years ago

Hmmm. This should happen automatically. Maybe the definition of NSString in the internal headers is doing something weird, and not explicitly extending NSObject?

I suppose we can hard code this behavior.

brianquinlan commented 2 years ago

The declaration for NSString looks like:

@interface NSString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
brianquinlan commented 2 years ago

Hmmm... yeah, I see that this usually works but didn't for NSString for some reason.