Skip to content

Commit 81ae746

Browse files
committed
[BitwiseCopyable] Don't diagnose implicit checks.
Previously, the diagnostics for conforming a non-escaping or non-copyable type to `_BitwiseCopyable` were emitted even in the case of an implicit check for conformance. Here this is fixed to suppress the diagnostics in the case of an implicit check as is done for other diagnostics.
1 parent 906d261 commit 81ae746

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

lib/Sema/TypeCheckBitwise.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,16 @@ static bool checkBitwiseCopyableInstanceStorage(NominalTypeDecl *nominal,
224224
KnownProtocolKind::BitwiseCopyable));
225225

226226
if (dc->mapTypeIntoContext(nominal->getDeclaredInterfaceType())->isNoncopyable()) {
227-
nominal->diagnose(diag::non_bitwise_copyable_type_noncopyable);
227+
if (!isImplicit(check)) {
228+
nominal->diagnose(diag::non_bitwise_copyable_type_noncopyable);
229+
}
228230
return true;
229231
}
230232

231233
if (!dc->mapTypeIntoContext(nominal->getDeclaredInterfaceType())->isEscapable()) {
232-
nominal->diagnose(diag::non_bitwise_copyable_type_nonescapable);
234+
if (!isImplicit(check)) {
235+
nominal->diagnose(diag::non_bitwise_copyable_type_nonescapable);
236+
}
233237
return true;
234238
}
235239

test/Sema/bitwise_copyable.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ struct S_Explicit_Nonescapable : ~Escapable, _BitwiseCopyable {} // expected-err
193193

194194
struct S_Explicit_Noncopyable : ~Copyable, _BitwiseCopyable {} // expected-error{{non_bitwise_copyable_type_noncopyable}}
195195

196+
struct S_Implicit_Nonescapable : ~Escapable {}
197+
198+
struct S_Implicit_Noncopyable : ~Copyable {}
199+
200+
196201
func passUnmanaged<T : AnyObject>(_ u: Unmanaged<T>) { take3(u) }
197202

198203
struct S_Explicit_With_Unmanaged<T : AnyObject> : _BitwiseCopyable {

test/Sema/bitwise_copyable_2.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-typecheck-verify-swift \
2+
// RUN: -disable-availability-checking \
3+
// RUN: -enable-experimental-feature NonescapableTypes \
4+
// RUN: -enable-experimental-feature BitwiseCopyable \
5+
// RUN: -enable-builtin-module \
6+
// RUN: -debug-diagnostic-names
7+
8+
// This test file only exists in order to test without noncopyable_generics and can be deleted once that is always enabled.
9+
10+
@_nonescapable
11+
struct S_Implicit_Nonescapable {}
12+
13+
struct S_Implicit_Noncopyable : ~Copyable {}

0 commit comments

Comments
 (0)