Sema: More accurate VarDeclUsageChecker analysis with local functions

We used to take all the captures of a local function and treat them all
as read and write usages of vars from an outer scope. Instead, let's
refactor the analysis to walk into local functions.
This commit is contained in:
Slava Pestov
2020-04-03 17:28:02 -04:00
parent 93f0faf109
commit 2c2d087242
10 changed files with 57 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
// RUN: %target-swift-emit-silgen -verify %s | %FileCheck %s
if true {
var x = 0
var x = 0 // expected-warning {{variable 'x' was never mutated; consider changing to 'let' constant}}
func local() -> Int { return 0 }
func localWithContext() -> Int { return x }
func transitiveWithoutContext() -> Int { return local() }