Skip to content

Commit 5685121

Browse files
committed
fix <rdar://problem/20911927> False positive in the "variable was never mutated" warning with IUO
Swift SVN r28583
1 parent 7d089a9 commit 5685121

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,8 @@ markBaseOfAbstractStorageDeclStore(Expr *base, ConcreteDeclRef decl) {
10681068
if (auto *TEE = dyn_cast<TupleElementExpr>(E))
10691069
return markStoredOrInOutExpr(TEE->getBase(), Flags);
10701070

1071+
if (auto *FVE = dyn_cast<ForceValueExpr>(E))
1072+
return markStoredOrInOutExpr(FVE->getSubExpr(), Flags);
10711073

10721074
// If we don't know what kind of expression this is, assume it's a reference
10731075
// and mark it as a read.

test/decl/var/usage.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,12 @@ func testTuple() {
133133
var tup : (x:Int, y:Int) // expected-warning {{variable 'tup' was written to, but never read}}
134134
tup.x = 1
135135
}
136+
137+
138+
/// <rdar://problem/20911927> False positive in the "variable was never mutated" warning with IUO
139+
func testForceValueExpr() {
140+
var a: X! = nil // no warning, mutated through the !
141+
a!.g()
142+
}
143+
144+

0 commit comments

Comments
 (0)