Skip to content

Commit 85246bc

Browse files
[test] Add regression test for SR-15562
1 parent b250723 commit 85246bc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11662,7 +11662,7 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix, unsigned impact) {
1166211662
// its sub-expressions.
1166311663
llvm::SmallDenseSet<ASTNode> anchors;
1166411664
for (const auto *fix : Fixes) {
11665-
// Warning fixes shouldn't be considered, because even if
11665+
// Warning fixes shouldn't be considered because even if
1166611666
// such fix is recorded at that anchor this should not
1166711667
// have any affect in the recording of any other fix.
1166811668
if (fix->isWarning())

test/Constraints/casts.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,3 +651,14 @@ struct SR15281_SC {
651651
a.flatMap(SR15281_CC.init(a:)) // expected-error{{cannot convert return expression of type 'SR15281_CC?' to return type 'SR15281_BC'}} {{35-35=!}}
652652
}
653653
}
654+
655+
// SR-15562
656+
func test_SR_15562() {
657+
let foo: [Int: Int] = [:]
658+
let bar = [1, 2, 3, 4]
659+
660+
for baz in bar {
661+
foo[baz] as! Int += 1 // expected-warning{{forced cast from 'Int?' to 'Int' only unwraps optionals; did you mean to use '!'?}}
662+
// expected-error@-1{{left side of mutating operator has immutable type 'Int'}}
663+
}
664+
}

0 commit comments

Comments
 (0)