Skip to content

Commit c26cafc

Browse files
committed
AST: Remove bogus PackExpansionType logic in lookupConformance()
1 parent 50afb00 commit c26cafc

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

lib/AST/Module.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,18 +1949,6 @@ LookupConformanceInModuleRequest::evaluate(
19491949
return getBuiltinBuiltinTypeConformance(type, builtinType, protocol);
19501950
}
19511951

1952-
// Specific handling of Copyable and Sendable for pack expansions.
1953-
// FIXME: Remove.
1954-
if (auto packExpansion = type->getAs<PackExpansionType>()) {
1955-
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable) ||
1956-
protocol->isSpecificProtocol(KnownProtocolKind::Sendable)) {
1957-
auto patternType = packExpansion->getPatternType();
1958-
return (patternType->isTypeParameter()
1959-
? ProtocolConformanceRef(protocol)
1960-
: mod->lookupConformance(patternType, protocol));
1961-
}
1962-
}
1963-
19641952
auto nominal = type->getAnyNominal();
19651953

19661954
// If we don't have a nominal type, there are no conformances.

lib/AST/Type.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ bool TypeBase::isPureMoveOnly() {
160160
if (auto *nom = getAnyNominal())
161161
return nom->isMoveOnly();
162162

163+
if (auto *expansion = getAs<PackExpansionType>()) {
164+
return expansion->getPatternType()->isPureMoveOnly();
165+
}
166+
163167
// if any components of the tuple are move-only, then the tuple is move-only.
164168
if (auto *tupl = getCanonicalType()->getAs<TupleType>()) {
165169
for (auto eltTy : tupl->getElementTypes())

lib/Sema/CSSimplify.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8293,6 +8293,17 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
82938293
return SolutionKind::Solved;
82948294
}
82958295

8296+
// We sometimes get a pack expansion type here.
8297+
if (auto *expansionType = type->getAs<PackExpansionType>()) {
8298+
// FIXME: Locator
8299+
addConstraint(ConstraintKind::ConformsTo,
8300+
expansionType->getPatternType(),
8301+
protocol->getDeclaredInterfaceType(),
8302+
locator);
8303+
8304+
return SolutionKind::Solved;
8305+
}
8306+
82968307
// Copyable is checked structurally, so for better performance, split apart
82978308
// this constraint into individual Copyable constraints on each tuple element.
82988309
if (auto *tupleType = type->getAs<TupleType>()) {

test/Generics/tuple-conformances.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func useConformance() {
3838
////
3939

4040
extension Builtin.TheTupleType: Equatable where repeat each Elements: Equatable {
41+
// FIXME: Hack
42+
@_disfavoredOverload
4143
public static func ==(lhs: Self, rhs: Self) -> Bool {
4244
var result = true
4345
func update<E: Equatable>(lhs: E, rhs: E) {

0 commit comments

Comments
 (0)