mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This is legal Objective-C code:
typedef NSBar <NSFooing> BarAndFoo
@interface MyBaz : BarAndFoo
@end
// Equivalent
@interface MyBaz : NSBar <NSFooing>
@end
In Swift 3, we usually handled these by just dropping the protocol
part, making everything appear to work. (The protocols get added to
the class later, without looking at sugar.) However, in Swift 4, we
started supporting these compositions directly* and suddenly
inheriting from them didn't work (read: crashed the compiler). As an
extra twist, even Swift 3 can hit the problem case when the base type
is NSObject, because we figured 'id <NSObject, NSFooing>' was a better
approximation of 'NSObject <NSFooing> *' than 'NSObject *' was.
Fix this by just ignoring protocols when looking for a superclass. As
mentioned, we attach those separately anyway, so we aren't losing any
information.
* This isn't exactly true; there's still a difference between
'NSBar <NSFooing>' and 'NSBar <NSFooing> *'. Jacopo Andrea Giola fixed
a previous issue with this in a598277ad. But Swift doesn't do anything
meaningful with the first form, so it usually just pretends it's the
second.
rdar://problem/34586035
13 lines
307 B
Objective-C
13 lines
307 B
Objective-C
@import Foundation;
|
|
|
|
@interface SomeSpecificSubclass : NSObject
|
|
@end
|
|
|
|
typedef NSObject <NSCopying> CopyableNSObjectBase;
|
|
typedef SomeSpecificSubclass <NSCopying> CopyableSpecificBase;
|
|
|
|
@interface CompositionSubObject : CopyableNSObjectBase
|
|
@end
|
|
@interface CompositionSubSpecific : CopyableSpecificBase
|
|
@end
|