enum MyEnum: Equatable {
case firstCase
case secondCase
case thirdCase(value: Int)
}
expect(MyEnum.firstCase).to(equal(.secondCase)) // this is fine
expect(MyEnum.firstCase).to(equal(.thirdCase(value: 10))) // this is also fine
var optionalEnum: MyEnum?
optionalEnum = .firstCase
expect(optionalEnum).to(equal(.secondCase)) // this is fine
expect(optionalEnum).to(equal(.thirdCase(value: 10))) // this produces warning that we are using old API ('to(_:description:)' is deprecated: Use Predicate instead)
When expected value is of an optional type and matcher value uses enum with associated value the old API is used.
expect(optionalEnum).to(equal(.thirdCase(value: 10))) should create Predicate instead of a Matcher.
Matcher was used resulting in deprecated warning.
List the software versions you're using:
Please also mention which package manager you used and its version. Delete the
other package managers in this list:
Example code above.
I'm really not sure why Swift 5.3 compiler pick this up only for such specific case 馃
let third = MyEnum.thridCase(value: 10)
expect(optionalEnum).to(equal(third))
This uses the expected to. So I think this might be a compiler issue (regarding type inference).
I think you are right. Even providing the type explicitly fixes the warning:
expect(optionalEnum).to(equal(MyEnum.thirdCase(value: 10)))
Seeing the same problem too!
I'm also seeing this issue.
I Just created a patch for this issue, let's hope the maintainers will have a look at it ;)
@ikesyo any updates on this issue? When can we expect a major version bump?
Getting something similar here in Xcode 12.3:
let actualCommentIds: [Comment] = // ...
expect(actualCommentIds).toEventually(equal([comment.id]))
Something to do with the automatic conformance of Array<Equatable> to Equatable?
I tested this on Xcode 12.5 and doesn't happen anymore. Looks like the overload resolution is fixed/improved in Swift 5.4. Closing.
Most helpful comment
I Just created a patch for this issue, let's hope the maintainers will have a look at it ;)