Static when calling closure expressions

The following fails, because Silver requires test_passes and test_fails to be static:

class MyTestCase: XCTestCase {
    static var allTests = {
        return [
            ("test_passes", test_passes),  // E: "test_passes" is not static
            ("test_fails", test_fails),  // E: "test_fails" is not static
        ]
    }()

    func test_passes() {
        XCTAssert(true)
    }

    func test_fails() {
        XCTAssert(false)
    }
}

Hmm. I don’t see how they could not be required to. a static method/property, allTests cannot access/call instance members of a type.

what should this compile to? what’t the (implied) return type of allTests, an array of tuples of a string and what exactly?

Yeah, I was thinking about this, too. I couldn’t find the right part of the language spec to see what is supposed to happen here, but this is how Apple writes their test cases. With their compiler allTests is of type [(String, (MyTestCase) -> () -> ())].

Ugh. @ck, any thoughts?

Curious, why the double delegate? In any case it seems that Swift allows (MyTestcase) -> () to point to a static method and call it through that.

So basically this:

typealias test = (MyClass) -> ()

class MyClass {
    static var inst: test = TakeThis;
    func TakeThis() {
        
    }
}

should work. I’ll create an issue.

Thanks, logged as bugs://81986

bugs://81986 got closed with status fixed.

Apple’s compiler is not happy with the above:
Cannot convert value of type '(MyClass) -> () -> ()' to specified type 'test' (aka '(MyClass) -> ()')

hrmm this is quite odd. From the error it seems it returns a delegate that takes an instance of the class and returns delegate. Fairly indirect. Ill investigate further.