Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Generated code for a protocol which requires a generic initializer cause a compiler error

Open myihsan opened this issue 4 years ago • 2 comments

protocol SomeProtocol {
    init<T>(t: T)
}

The code generated by the protocol above will have an initializer like below which cause a compiler error.

     required init(t: T) {
        
    }

It looks like the type placeholder is missing when generating for an initializer.

myihsan avatar Aug 03 '20 13:08 myihsan

Hi, @myihsan. This seems like a forgotten generic parameters string in the mock template, should be a fairly easy fix. Though the tests should have contained a generic init, I must have overlooked this.

MatyasKriz avatar Aug 03 '20 19:08 MatyasKriz

Hey, I fixed this issue in the fix/protocol-generic-init, though I found out that generic methods in protocols aren't supported either. I'm not sure if it's possible to add that functionality with the current way it works, so I'll keep you posted in case I think of something and have the time to implement it.

MatyasKriz avatar Aug 22 '20 18:08 MatyasKriz