Skip to content

Commit fa293a4

Browse files
committed
Fix TypeLowering: BitwiseCopyable archetypes are trivial
1 parent d5b3079 commit fa293a4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/swift/SIL/SILTypeProperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class SILTypeProperties {
241241
return HasRawLayout_t((Flags & HasRawLayoutFlag) != 0);
242242
}
243243

244+
void setTrivial() { Flags &= ~NonTrivialFlag; }
244245
void setNonTrivial() { Flags |= NonTrivialFlag; }
245246
void setIsOrContainsRawPointer() { Flags |= HasRawPointerFlag; }
246247

lib/SIL/IR/TypeLowering.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,18 @@ namespace {
772772
type, getReferenceSILTypeProperties(isSensitive));
773773
}
774774
}
775-
return asImpl().handleAddressOnly(
776-
type, getOpaqueSILTypeProperties(isSensitive));
775+
auto props = getOpaqueSILTypeProperties(isSensitive);
776+
if (ProtocolDecl *bitwiseCopyable =
777+
TC.Context.getProtocol(KnownProtocolKind::BitwiseCopyable)) {
778+
// If a context is available, then the caller will have mapped into it.
779+
// Opaque function type results still have interface types here.
780+
if (auto conformance =
781+
checkConformanceWithoutContext(type, bitwiseCopyable)) {
782+
if (!conformance->isInvalid())
783+
props.setTrivial();
784+
}
785+
}
786+
return asImpl().handleAddressOnly(type, props);
777787
}
778788

779789
RetTy visitExistentialType(CanType type,

0 commit comments

Comments
 (0)