Skip to content

Commit a7b50c0

Browse files
authored
Merge pull request swiftlang#79489 from slavapestov/fix-rdar145092838
Sema: Don't record constraints containing UnboundGenericType from shrink()
2 parents e866868 + 521ea46 commit a7b50c0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,10 @@ bool ConstraintSystem::Candidate::solve(
858858
auto constraintKind = ConstraintKind::Conversion;
859859
if (CTP == CTP_CallArgument)
860860
constraintKind = ConstraintKind::ArgumentConversion;
861-
862-
cs.addConstraint(constraintKind, cs.getType(E), CT,
863-
cs.getConstraintLocator(E), /*isFavored=*/true);
861+
if (!CT->hasUnboundGenericType()) {
862+
cs.addConstraint(constraintKind, cs.getType(E), CT,
863+
cs.getConstraintLocator(E), /*isFavored=*/true);
864+
}
864865
}
865866

866867
// Try to solve the system and record all available solutions.

test/Constraints/rdar145092838.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
func f(a: Array<Int>, n: Int) {
4+
let _: Array = a.prefix(n) + a.suffix(a.count - n - 1)
5+
}

0 commit comments

Comments
 (0)