22//
33// This source file is part of the Swift.org open source project
44//
5- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+ // Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66// Licensed under Apache License v2.0 with Runtime Library Exception
77//
88// See https://swift.org/LICENSE.txt for license information
@@ -2295,37 +2295,28 @@ struct TargetTypeMetadataRecord {
22952295 union {
22962296 // / A direct reference to a nominal type descriptor.
22972297 RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298- TypeReferenceKind >
2298+ TypeMetadataRecordKind >
22992299 DirectNominalTypeDescriptor;
23002300
23012301 // / An indirect reference to a nominal type descriptor.
23022302 RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303- TypeReferenceKind >
2303+ TypeMetadataRecordKind >
23042304 IndirectNominalTypeDescriptor;
2305-
2306- // We only allow a subset of the TypeReferenceKinds here.
2307- // Should we just acknowledge that this is a different enum?
23082305 };
23092306
23102307public:
2311- TypeReferenceKind getTypeKind () const {
2308+ TypeMetadataRecordKind getTypeKind () const {
23122309 return DirectNominalTypeDescriptor.getInt ();
23132310 }
23142311
23152312 const TargetContextDescriptor<Runtime> *
23162313 getContextDescriptor () const {
23172314 switch (getTypeKind ()) {
2318- case TypeReferenceKind ::DirectTypeDescriptor:
2315+ case TypeMetadataRecordKind ::DirectTypeDescriptor:
23192316 return DirectNominalTypeDescriptor.getPointer ();
23202317
2321- case TypeReferenceKind ::IndirectTypeDescriptor:
2318+ case TypeMetadataRecordKind ::IndirectTypeDescriptor:
23222319 return *IndirectNominalTypeDescriptor.getPointer ();
2323-
2324- // These types (and any others we might add to TypeReferenceKind
2325- // in the future) are just never used in these lists.
2326- case TypeReferenceKind::DirectObjCClassName:
2327- case TypeReferenceKind::IndirectObjCClass:
2328- return nullptr ;
23292320 }
23302321
23312322 return nullptr ;
@@ -2415,6 +2406,9 @@ struct TargetTypeReference {
24152406 // / A direct reference to an Objective-C class name.
24162407 RelativeDirectPointer<const char >
24172408 DirectObjCClassName;
2409+
2410+ // / A "reference" to some metadata kind, e.g. tuple.
2411+ MetadataKind MetadataKind;
24182412 };
24192413
24202414 const TargetContextDescriptor<Runtime> *
@@ -2428,12 +2422,18 @@ struct TargetTypeReference {
24282422
24292423 case TypeReferenceKind::DirectObjCClassName:
24302424 case TypeReferenceKind::IndirectObjCClass:
2425+ case TypeReferenceKind::MetadataKind:
24312426 return nullptr ;
24322427 }
24332428
24342429 return nullptr ;
24352430 }
24362431
2432+ enum MetadataKind getMetadataKind (TypeReferenceKind kind) const {
2433+ assert (kind == TypeReferenceKind::MetadataKind);
2434+ return MetadataKind;
2435+ }
2436+
24372437#if SWIFT_OBJC_INTEROP
24382438 // / If this type reference is one of the kinds that supports ObjC
24392439 // / references,
@@ -2519,6 +2519,10 @@ struct TargetProtocolConformanceDescriptor final
25192519 return Flags.getTypeReferenceKind ();
25202520 }
25212521
2522+ enum MetadataKind getMetadataKind () const {
2523+ return TypeRef.getMetadataKind (getTypeKind ());
2524+ }
2525+
25222526 const char *getDirectObjCClassName () const {
25232527 return TypeRef.getDirectObjCClassName (getTypeKind ());
25242528 }
@@ -2546,6 +2550,11 @@ struct TargetProtocolConformanceDescriptor final
25462550 TargetRelativeContextPointer<Runtime>>();
25472551 }
25482552
2553+ // / Whether this conformance is builtin by the compiler + runtime.
2554+ bool isBuiltin () const {
2555+ return getTypeKind () == TypeReferenceKind::MetadataKind;
2556+ }
2557+
25492558 // / Whether this conformance is non-unique because it has been synthesized
25502559 // / for a foreign type.
25512560 bool isSynthesizedNonUnique () const {
0 commit comments