swiftlang/swift

[SR-8536] Warn on member assignments capturing self

オープン

#51,055 opened on 2018/08/14

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)Swift (10,719 件のフォーク)batch import
compilergood first issueimprovementtype checker

Repository metrics

Stars
 (69,989 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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.

コントリビューターガイド