Skip to content

Commit 7d89bbf

Browse files
Merge pull request #72639 from nate-chandler/cherrypick/release/6.0/rdar125443922
6.0: [BitwiseCopyable] Loosen validation assertion.
2 parents 6f5fc1f + 2424e74 commit 7d89bbf

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,11 +3203,13 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
32033203
}
32043204
}
32053205

3206-
if (!lowering.isTrivial() && conformance) {
3206+
if (!lowering.isTrivial() && conformance &&
3207+
!conformance.hasUnavailableConformance()) {
32073208
// A non-trivial type can have a conformance in a few cases:
3208-
// (1) contains a conforming archetype
3209+
// (1) containing or being a conforming archetype
32093210
// (2) is resilient with minimal expansion
32103211
// (3) containing or being ~Escapable
3212+
// (4) containing or being an opaque archetype
32113213
bool hasNoConformingArchetypeNode = visitAggregateLeaves(
32123214
origType, substType, forExpansion,
32133215
/*isLeaf=*/
@@ -3256,6 +3258,11 @@ void TypeConverter::verifyTrivialLowering(const TypeLowering &lowering,
32563258
if (origTy.isTypeParameter())
32573259
return false;
32583260

3261+
// An opaque archetype may conform but be non-trivial (case (4)).
3262+
if (isa<OpaqueTypeArchetypeType>(ty)) {
3263+
return false;
3264+
}
3265+
32593266
return true;
32603267
});
32613268
if (hasNoConformingArchetypeNode) {

test/SILGen/bitwise_copyable.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ public enum E : _BitwiseCopyable {
4747
func take<T : _BitwiseCopyable>(_ t: T) {}
4848

4949
func pass(_ e: E) { take(e) }
50+
51+
func opacify() -> some _BitwiseCopyable {
52+
return Int()
53+
}
54+
55+
struct NeverGoingToBeBitwiseCopyable {
56+
var a: AnyObject
57+
}
58+
59+
@available(*, unavailable)
60+
extension NeverGoingToBeBitwiseCopyable : _BitwiseCopyable {
61+
}

0 commit comments

Comments
 (0)