Skip to content

Commit 1977880

Browse files
committed
add a Copyable catch-all for non-nominals
After filtering out aggregates when determining if a type is Copyable, its safe to say that a type is Copyable if its not a nominal. The only types that are not copyable at the moment are move-only nominals and tuples containing such types.
1 parent 6c7fc72 commit 1977880

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/AST/Module.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,11 @@ LookupConformanceInModuleRequest::evaluate(
16461646

16471647
auto nominal = type->getAnyNominal();
16481648

1649+
// If it's not a nominal, then it's safe to assume its copyable.
1650+
if (!nominal && protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
1651+
return ProtocolConformanceRef(protocol);
1652+
}
1653+
16491654
// If we don't have a nominal type, there are no conformances.
16501655
if (!nominal || isa<ProtocolDecl>(nominal))
16511656
return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);

test/type/pack_expansion.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ func invalidPackRef(_: each Int) {}
7474

7575
// expected-error@+1 {{pack reference 'T' can only appear in pack expansion or generic requirement}}
7676
func packRefOutsideExpansion<each T>(_: each T) {}
77+
78+
// coverage to ensure a 'repeat each' type is considered Copyable
79+
func golden<Z>(_ z: Z) {}
80+
func hour<each T>(_ t: repeat each T) {
81+
golden(t)
82+
}

0 commit comments

Comments
 (0)