Closed kitwtnb closed 1 year ago
@kitwtnb thanks for flagging this, I'll get it fixed. In the meantime, you can work around it by disabling the redundantStaticSelf
rule (cc @sjavora).
@kitwtnb fixed in 0.52.1
@nicklockwood
Thank you very much.
The above pattern has been fixed, but the following pattern will now remove the required Self
.
0.52.1
class Foo {
static let bar = 0
func f() {
let a = Self.bar
}
}
↓
class Foo {
static let bar = 0
func f() {
let a = bar
}
}
@kitwtnb I'm not able to reproduce that with 0.52.1. Can you double check you're using the right version and that particular code snippet reproduces the issue?
@nicklockwood
The following steps were used to reproduce the results.
./Foo.swift
.class Foo {
static let bar = 0
func f() {
let a = Self.bar
}
}
Run it using Mint.
mint run nicklockwood/SwiftFormat@0.52.1 Foo.swift
Self
has been removed.
@kitwtnb with that exact process and those exact file contents, I'm seeing no changes. I have found a bug involving let
or if let
expressions, so for the following code Self
is currently removed by 0.52.1, but not for the example you gave, which seems odd.
class Foo {
static let bar = 0
func f() {
if let a = Self.bar {
print("oops")
}
}
}
It is also reproduced in 0.52.1.
However, this has been corrected in 0.52.2. Thank you very much!
The following enum is defined.
In 0.51.15, it is not rewritten.
In 0.52.0, it was rewritten as follows, and the compilation no longer passes.