swiftlang/swift

[SR-8536] Warn on member assignments capturing self

开放

#51,055 创建于 2018年8月14日

 (2 条评论) (0 个反应) (0 位负责人)Swift (10,719 个派生)batch import
compilergood first issueimprovementtype checker

仓库指标

星标
 (69,989 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Previous ID SR-8536
Radar None
Original Reporter @CodaFi
Type Improvement
Votes 2
Component/s Compiler
Labels Improvement, StarterBug, TypeChecker
Assignee tt (JIRA)
Priority Medium

md5: cb331d15432b248f57b7b7bce4d077f7

Issue Description:

class Foo {
  let bar: () -> ()

  func baz() {}

  init() {
    self.bar = baz // We oughta warn about capturing 'self' implicitly.
  }
}

In the example above, we should warn about capturing `self` implicitly and, rather than suggest the user make it explicit, probably offer a fixit that provides a closure with a weak or unowned capture.

贡献者指南