Compiler fails when swift extension defines protocol on cpp class (with static func)

Hello,

I think this should work, but maybe I'm misunderstanding something about cpp interop... so before I bug it.

I have a class in cpp:

class Test {
public:
    static void hellostatic() {
        printf("hello from hellostatic\n");
    };
    
    void hello() {
        printf("hello from cpp\n");
    };
    
    Test() = default;
    Test(Test &other) = default;
    ~Test() = default;
};

I can call both the hello() func and hellostatic() funcs from swift:

var t = Test()
t.hello()
Test.hellostatic()

But if I try to create a protocol in swift conform the cpp object to it with an extension, the compiler will fail.

protocol Friendly {
    mutating func hello()
   // static func hellostatic() <- uncommenting this will cause compilation to fail
}

extension Test: Friendly {}
var t = Test()
t.hello()

Test.hellostatic()

Misunderstanding on my part? Bug?

mike

1 Like