Skip to content

Commit cf5531b

Browse files
authored
Merge pull request swiftlang#67489 from xedin/rdar-110847476
[CSSimplify] Fix invalid diagnostics emitted for a pack reference outside of pack expansion
2 parents be34674 + d5bb55e commit cf5531b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5093,7 +5093,7 @@ bool ConstraintSystem::repairFailures(
50935093
if (auto objType = valueType->getOptionalObjectType())
50945094
valueType = objType;
50955095

5096-
if (rawReprType->isTypeVariableOrMember())
5096+
if (rawReprType->isTypeVariableOrMember() || rawReprType->isPlaceholder())
50975097
return false;
50985098

50995099
auto rawValue = isRawRepresentable(*this, rawReprType);
@@ -5350,6 +5350,11 @@ bool ConstraintSystem::repairFailures(
53505350
if (repairByUsingRawValueOfRawRepresentableType(lhs, rhs))
53515351
return true;
53525352

5353+
// If either side is a placeholder then let's consider this
5354+
// assignment correctly typed.
5355+
if (lhs->isPlaceholder() || rhs->isPlaceholder())
5356+
return true;
5357+
53535358
// Let's try to match source and destination types one more
53545359
// time to see whether they line up, if they do - the problem is
53555360
// related to immutability, otherwise it's a type mismatch.

test/Constraints/pack-expansion-expressions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,15 @@ do {
722722
_ = value.data.key // Ok
723723
}
724724
}
725+
726+
// rdar://110847476 - unrelated assignment and raw representable diagnostics
727+
do {
728+
struct Test<each Base: AsyncSequence> {
729+
let base: (repeat each Base)
730+
731+
init(base: repeat each Base) {
732+
self.base = base
733+
// expected-error@-1 {{pack reference 'each Base' can only appear in pack expansion}}
734+
}
735+
}
736+
}

0 commit comments

Comments
 (0)