Skip to content

Commit 05b4820

Browse files
committed
Revert "[BitwiseCopyable] Don't derive on @unchecked field"
This reverts commit d9e1755.
1 parent 990c318 commit 05b4820

File tree

3 files changed

+1
-39
lines changed

3 files changed

+1
-39
lines changed

lib/Sema/TypeCheckBitwise.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ class BitwiseCopyableStorageVisitor : public StorageVisitor {
106106

107107
bool visitMemberDecl(ValueDecl *storage, Type ty);
108108
bool visitMemberType(Type type, SourceLoc loc);
109-
bool isUnchecked(ProtocolConformanceRef conformance);
110109
bool visitNonconformingMemberType(Type type, SourceLoc loc);
111110
void emitNonconformingMemberTypeDiagnostic(Type ty, SourceLoc loc);
112111
};
@@ -137,13 +136,6 @@ bool BitwiseCopyableStorageVisitor::visitMemberType(Type ty, SourceLoc loc) {
137136
return visitNonconformingMemberType(ty, loc);
138137
}
139138

140-
if (isImplicit(check) && isUnchecked(conformance)) {
141-
// Do not automatically derive conformance if one of the field's
142-
// conformance is @unchecked.
143-
invalid = true;
144-
return true;
145-
}
146-
147139
// Walk the conformance, diagnosing any missing BitwiseCopyable conformances.
148140
bool anyMissing = false;
149141
conformance.forEachMissingConformance(
@@ -158,20 +150,6 @@ bool BitwiseCopyableStorageVisitor::visitMemberType(Type ty, SourceLoc loc) {
158150
return anyMissing;
159151
}
160152

161-
bool BitwiseCopyableStorageVisitor::isUnchecked(
162-
ProtocolConformanceRef conformance) {
163-
if (!conformance.isConcrete())
164-
return false;
165-
auto concrete = conformance.getConcrete();
166-
assert(concrete);
167-
auto *root = concrete->getRootConformance();
168-
assert(root);
169-
auto *normal = dyn_cast<NormalProtocolConformance>(root);
170-
if (!normal)
171-
return false;
172-
return normal->isUnchecked();
173-
}
174-
175153
bool BitwiseCopyableStorageVisitor::visitNonconformingMemberType(
176154
Type ty, SourceLoc loc) {
177155
if (ty->hasError())

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,8 +2165,7 @@ static void diagnoseConformanceImpliedByConditionalConformance(
21652165
/// to the given protocol. This should return true when @unchecked can be
21662166
/// used to disable those semantic checks.
21672167
static bool hasAdditionalSemanticChecks(ProtocolDecl *proto) {
2168-
return proto->isSpecificProtocol(KnownProtocolKind::Sendable) ||
2169-
proto->isSpecificProtocol(KnownProtocolKind::BitwiseCopyable);
2168+
return proto->isSpecificProtocol(KnownProtocolKind::Sendable);
21702169
}
21712170

21722171
/// Determine whether the type \c T conforms to the protocol \c Proto,

test/Sema/bitwise_copyable.swift

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,6 @@ struct S_Explicit_With_Metatype_Optional_AnyObject : _BitwiseCopyable {
9494
var ty: Optional<AnyObject>.Type
9595
}
9696

97-
struct S_Unchecked : @unchecked _BitwiseCopyable {}
98-
99-
struct S_Implicit_With_S_Unchecked {
100-
var s: S_Unchecked
101-
}
102-
103-
func passS_Implicit_With_S_Unchecked(_ s: S_Implicit_With_S_Unchecked) {
104-
take1(s) // expected-error{{type_does_not_conform_decl_owner}}
105-
// expected-note@-92 {{where_requirement_failure_one_subst}}
106-
}
107-
108-
struct S_Explicit_With_S_Unchecked : _BitwiseCopyable {
109-
var s: S_Unchecked
110-
}
111-
11297
//==============================================================================
11398
//===========================DEPENDENCY-FREE TESTS=(END)======================}}
11499
//==============================================================================

0 commit comments

Comments
 (0)