-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override method with generic array argument generated with incorrect type #126
Comments
Just found out that the minimal example doesn't even involve generics. The following example also produces a duplicate method in the generated code: class Base {
func method(withArg: UInt) {
}
}
class Derived: Base {
override func method(withArg: UInt) {
}
} |
Thanks for the quick fix. I can confirm that the duplicate override method has been fixed when using the latest code in master. However another issue has still remained with regards to overriding methods with generics. class Concrete {
}
class Base<T> {
func method(vertices: [T]) {
}
}
class Derived: Base<Concrete> {
} It results in the following generated code: public final class DerivedMock: Mocky.Derived, Mockingbird.Mock {
...
// MARK: Mocked `method`(`vertices`: [T])
public override func `method`(`vertices`: [T]) -> Void {
let invocation: Mockingbird.Invocation = Mockingbird.Invocation(selectorName: "`method`(`vertices`: [T]) -> Void", arguments: [Mockingbird.ArgumentMatcher(`vertices`)], returnType: Swift.ObjectIdentifier((Void).self))
mockingContext.didInvoke(invocation) { () -> Void in
let implementation = stubbingContext.implementation(for: invocation)
if let concreteImplementation = implementation as? ([T]) -> Void {
concreteImplementation(`vertices`)
} else if let concreteImplementation = implementation as? () -> Void {
concreteImplementation()
}
}
}
...
} This results in the error Interestingly it does generate the correct code when the type parameter isn't an array I've tested this on a246a83 (master) |
Thanks for the update! The latest issue is caused by the type specializer not working recursively on type declarations. There isn’t a great workaround for this right now, but I’ll look into it for 0.13. |
The generator fails to handle the case where a derived class overrides a method with a generic type in its signature.
Minimal example:
The generated code this produces:
Xcode can't compile this because
is generated twice and it fails with a
method(withArg:) has already been overridden
Environment
The text was updated successfully, but these errors were encountered: