mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
class B<T> : NSFoo {}
class A : B<Int> {}
IRGen computes the ivar layout starting from offset zero, since
the size of the 'NSFoo' is unknown and we rely on the Objective-C
runtime to slide the ivar offsets.
The instantiated metadata for B<Int> would contain a field offset
vector with the correct offsets, because of how
swift_initClassMetadata_UniversalStrategy() works.
However, A's metadata is emitted statically, and this includes a
copy of the field offset vector from the superclass. A's metadata
was initialized by swift_initializeSuperclass(), which did not
copy the field offset vector over from A<Int>. And since the
Objective-C runtime only slides the immediate ivars of a class,
the field offsets corresponding to A<Int>'s fields in B's type
metadata were never slid, resulting in problems when an instance
of B was passed to a function operating on an A<T> generically.
Fixes <rdar://problem/23200051>.
22 lines
529 B
Objective-C
22 lines
529 B
Objective-C
#ifndef SWIFT_TEST_OBJC_CLASSES_H
|
|
#define SWIFT_TEST_OBJC_CLASSES_H
|
|
|
|
#include <Foundation/NSObject.h>
|
|
|
|
/* This class has instance variables which are not apparent in the
|
|
interface. Subclasses will need to be slid by the ObjC runtime. */
|
|
@interface HasHiddenIvars : NSObject
|
|
@property NSInteger x;
|
|
@property NSInteger y;
|
|
@property NSInteger z;
|
|
@property NSInteger t;
|
|
@end
|
|
|
|
/* This class has a method that doesn't fill in the error properly. */
|
|
@interface NilError : NSObject
|
|
+ (BOOL) throwIt: (NSError**) error;
|
|
@end
|
|
|
|
|
|
#endif
|