File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -1164,6 +1164,16 @@ struct TargetForeignClassMetadata : public TargetForeignTypeMetadata<Runtime> {
11641164};
11651165using ForeignClassMetadata = TargetForeignClassMetadata<InProcess>;
11661166
1167+ // / The structure of metadata objects for foreign reference types.
1168+ // / A foreign reference type is a non-Swift, non-Objective-C foreign type with
1169+ // / reference semantics. Foreign reference types are pointers/reference to
1170+ // / value types marked with the "import_as_ref" attribute.
1171+ // /
1172+ // / Foreign reference types may have *custom* reference counting operations, or
1173+ // / they may be immortal (and therefore trivial).
1174+ // /
1175+ // / We assume for now that foreign reference types are entirely opaque
1176+ // / to Swift introspection.
11671177template <typename Runtime>
11681178struct TargetForeignReferenceTypeMetadata : public TargetForeignTypeMetadata <Runtime> {
11691179 using StoredPointer = typename Runtime::StoredPointer;
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ NOMINALTYPEMETADATAKIND(Optional, 2 | MetadataKindIsNonHeap)
5353// / A foreign class, such as a Core Foundation class.
5454METADATAKIND(ForeignClass, 3 | MetadataKindIsNonHeap)
5555
56+ // / A non-Swift non-Objective-C class type.
5657METADATAKIND(ForeignReferenceType, 4 | MetadataKindIsNonHeap)
5758
5859// / A type whose value is not exposed in the metadata system.
Original file line number Diff line number Diff line change @@ -1787,8 +1787,7 @@ namespace {
17871787 // is a foreign class.
17881788 if ((IGM.IRGen .Opts .ReflectionMetadata !=
17891789 ReflectionMetadataMode::Runtime) ||
1790- getType ()->isForeign () ||
1791- getType ()->isForeignReferenceType ()) {
1790+ getType ()->isForeign ()) {
17921791 B.addInt32 (0 );
17931792 return ;
17941793 }
@@ -5430,6 +5429,9 @@ namespace {
54305429 ForeignClassMetadataBuilder (IRGenModule &IGM, ClassDecl *target,
54315430 ConstantStructBuilder &B)
54325431 : ForeignMetadataBuilderBase(IGM, target, B) {
5432+ assert (!getTargetType ()->isForeignReferenceType () &&
5433+ " foreign reference type metadata must be built with the ForeignReferenceTypeMetadataBuilder" );
5434+
54335435 if (IGM.getOptions ().LazyInitializeClassMetadata )
54345436 CanBeConstant = false ;
54355437 }
@@ -5559,11 +5561,6 @@ namespace {
55595561 }
55605562
55615563 void addSuperclass () {
5562- // Always leave the superclass pointer unfilled. We'll have to
5563- // unique it during initialization anyway, so we might as well spare
5564- // ourselves the load-time work.
5565- B.addNullPointer (IGM.TypeMetadataPtrTy );
5566-
55675564 assert (!Target->hasSuperclass () &&
55685565 " foreign reference types should not have superclasses." );
55695566 }
You can’t perform that action at this time.
0 commit comments