SwiftRewriter icon indicating copy to clipboard operation
SwiftRewriter copied to clipboard

Incorrect indentation of switch with pattern matching

Open taku0 opened this issue 4 years ago • 0 comments

Given:

enum Foo {
    case P(x: Int)
}
class A {
    func a() -> Bool {
        return true
    }
}

func foo() {
    switch Foo.P(x: 1) {
    case .P(1)
    where
      A()
        .a():
        print(1)
    case .P(let 2)
           where
             A()
               .a():
        print(2)
    case _:
        print("other")
    }
}

Output:

enum Foo {
    case P(x: Int)
}
class A {
    func a() -> Bool {
        return true
    }
}

func foo() {
    switch Foo.P(x: 1) {
    case .P(1)
        where
        A()
            .a():
            print(1)
        case .P(let 2)
            where
            A()
                .a():
                print(2)
            case _:
                print("other")
            }
        }

taku0 avatar Nov 17 '19 12:11 taku0