mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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() }
|
||||
|
||||
Reference in New Issue
Block a user