Skip to content

Commit 424802f

Browse files
authored
Revert SE-0283 (#34492)
Reverted despite build failures.
1 parent 142b726 commit 424802f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+100
-3033
lines changed

include/swift/ABI/Metadata.h

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 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,28 +2295,37 @@ struct TargetTypeMetadataRecord {
22952295
union {
22962296
/// A direct reference to a nominal type descriptor.
22972297
RelativeDirectPointerIntPair<TargetContextDescriptor<Runtime>,
2298-
TypeMetadataRecordKind>
2298+
TypeReferenceKind>
22992299
DirectNominalTypeDescriptor;
23002300

23012301
/// An indirect reference to a nominal type descriptor.
23022302
RelativeDirectPointerIntPair<TargetSignedPointer<Runtime, TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor>,
2303-
TypeMetadataRecordKind>
2303+
TypeReferenceKind>
23042304
IndirectNominalTypeDescriptor;
2305+
2306+
// We only allow a subset of the TypeReferenceKinds here.
2307+
// Should we just acknowledge that this is a different enum?
23052308
};
23062309

23072310
public:
2308-
TypeMetadataRecordKind getTypeKind() const {
2311+
TypeReferenceKind getTypeKind() const {
23092312
return DirectNominalTypeDescriptor.getInt();
23102313
}
23112314

23122315
const TargetContextDescriptor<Runtime> *
23132316
getContextDescriptor() const {
23142317
switch (getTypeKind()) {
2315-
case TypeMetadataRecordKind::DirectTypeDescriptor:
2318+
case TypeReferenceKind::DirectTypeDescriptor:
23162319
return DirectNominalTypeDescriptor.getPointer();
23172320

2318-
case TypeMetadataRecordKind::IndirectTypeDescriptor:
2321+
case TypeReferenceKind::IndirectTypeDescriptor:
23192322
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;
23202329
}
23212330

23222331
return nullptr;
@@ -2406,9 +2415,6 @@ struct TargetTypeReference {
24062415
/// A direct reference to an Objective-C class name.
24072416
RelativeDirectPointer<const char>
24082417
DirectObjCClassName;
2409-
2410-
/// A "reference" to some metadata kind, e.g. tuple.
2411-
MetadataKind MetadataKind;
24122418
};
24132419

24142420
const TargetContextDescriptor<Runtime> *
@@ -2422,18 +2428,12 @@ struct TargetTypeReference {
24222428

24232429
case TypeReferenceKind::DirectObjCClassName:
24242430
case TypeReferenceKind::IndirectObjCClass:
2425-
case TypeReferenceKind::MetadataKind:
24262431
return nullptr;
24272432
}
24282433

24292434
return nullptr;
24302435
}
24312436

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,10 +2519,6 @@ struct TargetProtocolConformanceDescriptor final
25192519
return Flags.getTypeReferenceKind();
25202520
}
25212521

2522-
enum MetadataKind getMetadataKind() const {
2523-
return TypeRef.getMetadataKind(getTypeKind());
2524-
}
2525-
25262522
const char *getDirectObjCClassName() const {
25272523
return TypeRef.getDirectObjCClassName(getTypeKind());
25282524
}
@@ -2550,11 +2546,6 @@ struct TargetProtocolConformanceDescriptor final
25502546
TargetRelativeContextPointer<Runtime>>();
25512547
}
25522548

2553-
/// Whether this conformance is builtin by the compiler + runtime.
2554-
bool isBuiltin() const {
2555-
return getTypeKind() == TypeReferenceKind::MetadataKind;
2556-
}
2557-
25582549
/// Whether this conformance is non-unique because it has been synthesized
25592550
/// for a foreign type.
25602551
bool isSynthesizedNonUnique() const {

include/swift/ABI/MetadataValues.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 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
@@ -361,19 +361,7 @@ enum : unsigned {
361361
NumGenericMetadataPrivateDataWords = 16,
362362
};
363363

364-
/// Kinds of type metadata reocrds.
365-
enum class TypeMetadataRecordKind : unsigned {
366-
/// A direct reference to a nominal type descriptor.
367-
DirectTypeDescriptor = 0x00,
368-
369-
/// An indirect reference to a nominal type descriptor.
370-
IndirectTypeDescriptor = 0x01,
371-
372-
First_Kind = DirectTypeDescriptor,
373-
Last_Kind = IndirectTypeDescriptor,
374-
};
375-
376-
/// Kinds of references to type metadata.
364+
/// Kinds of type metadata/protocol conformance records.
377365
enum class TypeReferenceKind : unsigned {
378366
/// The conformance is for a nominal type referenced directly;
379367
/// getTypeDescriptor() points to the type context descriptor.
@@ -396,14 +384,10 @@ enum class TypeReferenceKind : unsigned {
396384
/// unused.
397385
IndirectObjCClass = 0x03,
398386

399-
/// The conformance is for a non-nominal type whose metadata kind we recorded;
400-
/// getMetadataKind() returns the kind.
401-
MetadataKind = 0x04,
402-
403387
// We only reserve three bits for this in the various places we store it.
404388

405389
First_Kind = DirectTypeDescriptor,
406-
Last_Kind = MetadataKind,
390+
Last_Kind = IndirectObjCClass,
407391
};
408392

409393
/// Flag that indicates whether an existential type is class-constrained or not.

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ namespace swift {
103103
class InheritedProtocolConformance;
104104
class SelfProtocolConformance;
105105
class SpecializedProtocolConformance;
106-
class BuiltinProtocolConformance;
107106
enum class ProtocolConformanceState;
108107
class Pattern;
109108
enum PointerTypeKind : unsigned;
@@ -949,11 +948,6 @@ class ASTContext final {
949948
SelfProtocolConformance *
950949
getSelfConformance(ProtocolDecl *protocol);
951950

952-
/// Produce the builtin conformance for some structural type to some protocol.
953-
BuiltinProtocolConformance *
954-
getBuiltinConformance(Type type, ProtocolDecl *protocol,
955-
ArrayRef<ProtocolConformanceRef> conformances);
956-
957951
/// A callback used to produce a diagnostic for an ill-formed protocol
958952
/// conformance that was type-checked before we're actually walking the
959953
/// conformance itself, along with a bit indicating whether this diagnostic

include/swift/AST/ProtocolConformance.h

Lines changed: 4 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 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
@@ -66,10 +66,7 @@ enum class ProtocolConformanceKind {
6666
Specialized,
6767
/// Conformance of a generic class type projected through one of its
6868
/// superclass's conformances.
69-
Inherited,
70-
/// Builtin conformances are special conformaces that the runtime handles
71-
/// and isn't implemented directly in Swift.
72-
Builtin
69+
Inherited
7370
};
7471

7572
/// Describes the state of a protocol conformance, which may be complete,
@@ -332,9 +329,7 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
332329
/// - the type is directly declared to conform to the protocol (a
333330
/// normal conformance) or
334331
/// - the protocol's existential type is known to conform to itself (a
335-
/// self-conformance) or
336-
/// - the type's conformance is declared within the runtime (a builtin
337-
/// conformance).
332+
/// self-conformance).
338333
class RootProtocolConformance : public ProtocolConformance {
339334
protected:
340335
RootProtocolConformance(ProtocolConformanceKind kind, Type conformingType)
@@ -385,8 +380,7 @@ class RootProtocolConformance : public ProtocolConformance {
385380

386381
static bool classof(const ProtocolConformance *conformance) {
387382
return conformance->getKind() == ProtocolConformanceKind::Normal ||
388-
conformance->getKind() == ProtocolConformanceKind::Self ||
389-
conformance->getKind() == ProtocolConformanceKind::Builtin;
383+
conformance->getKind() == ProtocolConformanceKind::Self;
390384
}
391385
};
392386

@@ -1020,110 +1014,6 @@ class InheritedProtocolConformance : public ProtocolConformance,
10201014
}
10211015
};
10221016

1023-
/// A builtin conformance appears when a special non-nominal type has a runtime
1024-
/// declared conformance. E.g. the runtime implements Equatable for tuples.
1025-
class BuiltinProtocolConformance final : public RootProtocolConformance,
1026-
private llvm::TrailingObjects<BuiltinProtocolConformance,
1027-
ProtocolConformanceRef> {
1028-
friend ASTContext;
1029-
friend TrailingObjects;
1030-
1031-
ProtocolDecl *protocol = nullptr;
1032-
size_t numConformances;
1033-
1034-
mutable Optional<ArrayRef<Requirement>> conditionalConformances = None;
1035-
1036-
BuiltinProtocolConformance(Type conformingType, ProtocolDecl *protocol,
1037-
ArrayRef<ProtocolConformanceRef> conformances);
1038-
1039-
size_t numTrailingObjects(OverloadToken<ProtocolConformanceRef>) const {
1040-
return numConformances;
1041-
}
1042-
1043-
public:
1044-
/// Get the protocol being conformed to.
1045-
ProtocolDecl *getProtocol() const {
1046-
return protocol;
1047-
}
1048-
1049-
/// Get the trailing conformances that this builtin conformance needs.
1050-
MutableArrayRef<ProtocolConformanceRef> getConformances() {
1051-
return {getTrailingObjects<ProtocolConformanceRef>(), numConformances};
1052-
}
1053-
1054-
/// Get the trailing conformances that this builtin conformance needs.
1055-
ArrayRef<ProtocolConformanceRef> getConformances() const {
1056-
return {getTrailingObjects<ProtocolConformanceRef>(), numConformances};
1057-
}
1058-
1059-
/// Get any requirements that must be satisfied for this conformance to apply.
1060-
Optional<ArrayRef<Requirement>>
1061-
getConditionalRequirementsIfAvailable() const {
1062-
return ArrayRef<Requirement>();
1063-
}
1064-
1065-
/// Get any requirements that must be satisfied for this conformance to apply.
1066-
ArrayRef<Requirement> getConditionalRequirements() const;
1067-
1068-
/// Get the declaration context that contains the nominal type declaration.
1069-
DeclContext *getDeclContext() const {
1070-
return getProtocol();
1071-
}
1072-
1073-
/// Retrieve the state of this conformance.
1074-
ProtocolConformanceState getState() const {
1075-
return ProtocolConformanceState::Complete;
1076-
}
1077-
1078-
/// Get the kind of source from which this conformance comes.
1079-
ConformanceEntryKind getSourceKind() const {
1080-
return ConformanceEntryKind::Synthesized;
1081-
}
1082-
/// Get the protocol conformance which implied this implied conformance.
1083-
NormalProtocolConformance *getImplyingConformance() const {
1084-
return nullptr;
1085-
}
1086-
1087-
bool hasTypeWitness(AssociatedTypeDecl *assocType) const {
1088-
llvm_unreachable("builtin-conformances currently don't have associated \
1089-
types");
1090-
}
1091-
1092-
/// Retrieve the type witness and type decl (if one exists)
1093-
/// for the given associated type.
1094-
TypeWitnessAndDecl
1095-
getTypeWitnessAndDecl(AssociatedTypeDecl *assocType,
1096-
SubstOptions options=None) const {
1097-
llvm_unreachable("builtin-conformances currently don't have associated \
1098-
types");
1099-
}
1100-
1101-
/// Given that the requirement signature of the protocol directly states
1102-
/// that the given dependent type must conform to the given protocol,
1103-
/// return its associated conformance.
1104-
ProtocolConformanceRef
1105-
getAssociatedConformance(Type assocType, ProtocolDecl *protocol) const {
1106-
llvm_unreachable("builtin-conformances currently don't have associated \
1107-
types");
1108-
}
1109-
1110-
/// Retrieve the witness corresponding to the given value requirement.
1111-
ConcreteDeclRef getWitnessDeclRef(ValueDecl *requirement) const {
1112-
return ConcreteDeclRef(requirement);
1113-
}
1114-
1115-
/// Determine whether the witness for the given requirement
1116-
/// is either the default definition or was otherwise deduced.
1117-
bool usesDefaultDefinition(AssociatedTypeDecl *requirement) const {
1118-
llvm_unreachable("builtin-conformances currently don't have associated \
1119-
types");
1120-
}
1121-
1122-
static bool classof(const ProtocolConformance *conformance) {
1123-
return conformance->getKind() == ProtocolConformanceKind::Builtin;
1124-
}
1125-
};
1126-
11271017
inline bool ProtocolConformance::isInvalid() const {
11281018
return getRootConformance()->isInvalid();
11291019
}

include/swift/Frontend/BackDeploymentLibs.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
BACK_DEPLOYMENT_LIB((5, 0), all, "swiftCompatibility50")
2828
BACK_DEPLOYMENT_LIB((5, 1), all, "swiftCompatibility51")
29-
BACK_DEPLOYMENT_LIB((5, 3), all, "swiftCompatibility53")
3029
BACK_DEPLOYMENT_LIB((5, 0), executable, "swiftCompatibilityDynamicReplacements")
3130

3231
#undef BACK_DEPLOYMENT_LIB

include/swift/Remote/MetadataReader.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2017 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
@@ -1414,9 +1414,6 @@ class MetadataReader {
14141414

14151415
return metadataFn(metadata);
14161416
}
1417-
case TypeReferenceKind::MetadataKind: {
1418-
return None;
1419-
}
14201417
}
14211418

14221419
return None;

0 commit comments

Comments
 (0)