mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Don't record constraints containing UnboundGenericType from shrink()
Something changed here between the removal of shrink() and it's re-introduction, and we now record constraints that contain UnboundGenericType, which crashes in matchTypes(). As a narrow workaround, let's just ignore the contextual type if contains an UnboundGenericType. Fixes rdar://145092838.
This commit is contained in:
@@ -858,10 +858,11 @@ bool ConstraintSystem::Candidate::solve(
|
||||
auto constraintKind = ConstraintKind::Conversion;
|
||||
if (CTP == CTP_CallArgument)
|
||||
constraintKind = ConstraintKind::ArgumentConversion;
|
||||
|
||||
if (!CT->hasUnboundGenericType()) {
|
||||
cs.addConstraint(constraintKind, cs.getType(E), CT,
|
||||
cs.getConstraintLocator(E), /*isFavored=*/true);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to solve the system and record all available solutions.
|
||||
llvm::SmallVector<Solution, 2> solutions;
|
||||
|
||||
5
test/Constraints/rdar145092838.swift
Normal file
5
test/Constraints/rdar145092838.swift
Normal file
@@ -0,0 +1,5 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
func f(a: Array<Int>, n: Int) {
|
||||
let _: Array = a.prefix(n) + a.suffix(a.count - n - 1)
|
||||
}
|
||||
Reference in New Issue
Block a user