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> {
1164
1164
};
1165
1165
using ForeignClassMetadata = TargetForeignClassMetadata<InProcess>;
1166
1166
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.
1167
1177
template <typename Runtime>
1168
1178
struct TargetForeignReferenceTypeMetadata : public TargetForeignTypeMetadata <Runtime> {
1169
1179
using StoredPointer = typename Runtime::StoredPointer;
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ NOMINALTYPEMETADATAKIND(Optional, 2 | MetadataKindIsNonHeap)
53
53
// / A foreign class, such as a Core Foundation class.
54
54
METADATAKIND(ForeignClass, 3 | MetadataKindIsNonHeap)
55
55
56
+ // / A non-Swift non-Objective-C class type.
56
57
METADATAKIND(ForeignReferenceType, 4 | MetadataKindIsNonHeap)
57
58
58
59
// / 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 {
1787
1787
// is a foreign class.
1788
1788
if ((IGM.IRGen .Opts .ReflectionMetadata !=
1789
1789
ReflectionMetadataMode::Runtime) ||
1790
- getType ()->isForeign () ||
1791
- getType ()->isForeignReferenceType ()) {
1790
+ getType ()->isForeign ()) {
1792
1791
B.addInt32 (0 );
1793
1792
return ;
1794
1793
}
@@ -5430,6 +5429,9 @@ namespace {
5430
5429
ForeignClassMetadataBuilder (IRGenModule &IGM, ClassDecl *target,
5431
5430
ConstantStructBuilder &B)
5432
5431
: ForeignMetadataBuilderBase(IGM, target, B) {
5432
+ assert (!getTargetType ()->isForeignReferenceType () &&
5433
+ " foreign reference type metadata must be built with the ForeignReferenceTypeMetadataBuilder" );
5434
+
5433
5435
if (IGM.getOptions ().LazyInitializeClassMetadata )
5434
5436
CanBeConstant = false ;
5435
5437
}
@@ -5559,11 +5561,6 @@ namespace {
5559
5561
}
5560
5562
5561
5563
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
-
5567
5564
assert (!Target->hasSuperclass () &&
5568
5565
" foreign reference types should not have superclasses." );
5569
5566
}
You can’t perform that action at this time.
0 commit comments